Professional Documents
Culture Documents
Ds
Ds
A queue is an important data structure which is extensively used in computer applications. In this
chapter we will study the operations that can be performed on a queue. The chapter will also discuss
the implementation of a queue by using both arrays as well as linked lists.
Simple Queue or Linear Queue
Circular Queue
Priority Queue
Double Ended Queue (or Deque)
the tree traversal in the data structure. The term 'tree traversal' means traversing or visiting each node of a
tree.
Preorder traversal
Inorder traversal
Postorder traversal
A B-tree is a sort of self-balancing search tree whereby each node could have more than two children and
hold multiple keys. It's a broader version of the binary search tree. It is also usually called a height-
balanced m-way tree.
Deletion
Inserting
Searching and sorting
Traversal
Finding maximum value in BST
Finding minimum value in BST
7. Define hashing
Hashing is a technique or process of mapping keys, and values into the hash table by using a hash
function. It is done for faster access to elements. The efficiency of mapping depends on the efficiency of
the hash function used.
Part c
explain Asymptotic Notation with example
Following are the commonly used asymptotic notations to calculate the running time
complexity of an algorithm.
Ο Notation
Ω Notation
θ Notation
1. Big Oh Notation, Ο
The notation Ο(n) is the formal way to express the upper bound of an algorithm's running
time. It measures the worst case time complexity or the longest amount of time an algorithm
can possibly take to complete.
2. Omega Notation, Ω
The notation Ω(n) is the formal way to express the lower bound of an algorithm's running
time. It measures the best case time complexity or the best amount of time an algorithm can
possibly take to complete.
3. Theta Notation, θ
The notation θ(n) is the formal way to express both the lower bound and the upper bound of
an algorithm's running time. It is represented as follows
θ(f(n)) = { g(n) if and only if g(n) = Ο(f(n)) and g(n) = Ω(f(n)) for all n > n0. }
Time complexity of an algorithm refers to the amount of time an algorithm takes to run as a function of
the size of the input data. It is expressed in terms of the number of basic operations performed by the
algorithm.
Space complexity of an algorithm refers to the amount of memory or storage space required to solve a
problem. It is expressed in terms of the size of the input data.
The quick sort algorithm attempts to separate the list of elements into two parts and then sort each part
recursively. That means it use divide and conquer strategy. In quick sort, the partition of the list is
performed based on the element called pivot. Here pivot element is one of the elements in the list.
The list is divided into two partitions such that "all elements to the left of pivot are smaller than the pivot
and all elements to the right of pivot are greater than or equal to the pivot".
Step 1 - Consider the first element of the list as pivot (i.e., Element at first position in the list).
Step 2 - Define two variables i and j. Set i and j to first and last elements of the list respectively.
Step 3 - Increment i until list[i] > pivot then stop.
Step 4 - Decrement j until list[j] < pivot then stop.
Step 5 - If i < j then exchange list[i] and list[j].
Step 6 - Repeat steps 3,4 & 5 until i > j.
Step 7 - Exchange the pivot element with list[j] element.
return 0;
}
The left subtree of a node contains only nodes with keys lesser than the node’s key.
The right subtree of a node contains only nodes with keys greater than the node’s key.
The left and right subtree each must also be a binary search tree.
6. construct a bst for the given list