11 : Recursion Specifications & 12 : Graph Tree & Binary Search Tree & 13:Heap sort & 14: Hash Table.

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Graph Applications :

Computer Networks Electrical Circuits Road Map

Heap Sort

A sorting algorithm that works by first organizing the data to be sorted into a special type of binary tree called a heap

WHY to use Hash tables.

Hash tables are good for doing a quick search on things.

LEVELS INDICATE PRECEDENCE

The levels of the nodes in the tree indicate their relative precedence of evaluation (we do not need parentheses to indicate precedence).

LEVELS INDICATE PRECEDENCE ( cont 2)

The operation at the root is always the last operation performed.

binary heap data structures

is an array that can be viewed as a complete binary tree.

SUCCESSOR الاخ الي بعدك مباشرة اكبر منك الحالات ١ اذا كان عندك يمين : بدور على اصغر واحد يمينك اذا ما كان عندك يمين : بتطلع فوق اول يمين

successor (x ) = y, such that key [y] is the smallest key > key [x]

Heapify

switch parent and child until in min/max state step1 add nodes in order step2 swap using heapify step3 to output remove root step4 place last node as root step5 heapify step6 repeat until done

What is Graph?

A Graph is a data structure which consists of a set of vertices (Nodes), and a set of edges that connect (some of) them.

A Directed Graph or Digraph is a graph where each edge has a direction The edges in a digraph are called Arcs or Directed Edges

(1,4)=1→4 where 1 is the tail and 4 is the head

Graph Categorization :

- Directed Graph - Undirected Graph - Weighted Graph - Multigraph

How Function Calls Work

- When a function is called, it must have a storage area; which is used to Save CPU registers that the function changes, Save the return address, calling parameters, automatic local variables, and return value. - When the function returns, the storage area is released.

مما يتكون recursive method ؟

- base case : الحالة التي لا يتم فيها لاستعدء يعني متى راح يوقف - general case : الحالة الاهتيادية التي فيها كل مرة الاقتران بنادي نفسه على قيمة مختلفة عن التي قبلها

ايش اهم مثال على ال recursive method ؟

- factorial number . ( مضروب العدد ) Q) write a program to find the factorial for n ? {if (n== 1 ) return 1; else { return n * fact(n-1); } } - fibonacci number

Linked Representation of binary trees

--uses space more efficiently --provides additional flexibility --each node has two links: one to the left child of the node, and one to the right child of the node

A recursive process consists of two parts:

-A base (anchor) case that is processed without recursion. -A general case that is reduced to one or more smaller cases, thereby making progress towards eventually reducing the problem all the way to the base case.

SEARCHING FOR A KEY للبحث عن عنصر : - بتبلش من الرووت - اذا كان العنصر الي بتبحث عنه اكبر بتروح يمين - اذا طلع اصغر لتروح بسار

-Starting at the root : * trace down a path by comparing k with the key of the current node -If the keys are equal: we have found the key -If k < key[x] search in the left subtree of x -If k > key[x] search in the right subtree of x

HEAP ORDER PROPERTY

For every non-root node x, the parent is greater than or equal to x

HEAPIFY

Heapify picks the largest child key and compare it to the parent key. -

LEVELS INDICATE PRECEDENCE ( cont 1)

Operations at higher levels of the tree are evaluated later than those below them.

Repetition

Recursion or iteration

When not to use recursion

The recursion version will require more storage space and take more time as well.This is because it must store and retrieve all the numbers as well as multiply them.

how do we know that position stores the data that we are interested in?

This is where hashing comes in handy. Given some key, we can apply a hash function to it to find an index or position that we want to access.

A recursive procedure or function calls itself directly or indirectly.

true

Build Heap

العملية المسؤولة عن التنقل بين العقد لضمان تطبيق ال هيبفاي مما ينتج عنه goes through the remaining nodes of the tree and runs 'Heapify' on each one

ما الهدف من ال recursion ؟

تحل العمليات التي لايمكن حلها او يصعب عليه حلها باستخدام ال iteration .

ما هي recursive method ؟

عبارة عن اقتران بنادي حالو

Length : Sum of the lengths of the edges on the path. Length of the path 1,4,5,3 is 3

عدد ال nodes - 1 ;


संबंधित स्टडी सेट्स

IOWA DRIVER'S LICENSE PRACTICE TEST

View Set

Module 5: Renal Physiology (Acid-Base Balance and Buffering)

View Set

APUSH Chapters 1-41 Key Terms and People

View Set

CH 2- Workforce Safety and Wellness

View Set

Anatomy and physiology of speech mechanisms unit 1

View Set

Ch 13 - investing in mutual funds, ETF, and real estate

View Set

Life Insurance section 8: Social Security

View Set