Stack. S Array or Vector representing stack containing N elements

Size: px
Start display at page:

Download "Stack. S Array or Vector representing stack containing N elements"

Transcription

1 Stack Algorithm to Insert an element in a St ack: Procedure PUSH(S, TOP, X) X Value of element to be inserted in stack TOP A pointer ( or index) pointing to the top element of stack S Array or Vector representing stack containing N elements 1) [ Check for stack overflow] If TOP N then Write ( Stack Overflow ) 2) [ Increment TOP ] TOP TOP + 1 3) [ Insert element ] S[TOP] X 4) [ Finished ] Algorithm to Delete an element from a St ack: Function POP(S, TOP) TOP A pointer ( or index) pointing to the top element of stack S Array or Vector representing stack containing N elements 1) [ Check for underflow on stack ] If TOP = 0 then Write ( Stack Underflow on POP ) 2) [ Decrement Pointer TOP ] TOP TOP - 1 3) [ former top eleme nt of stack ] ( S[ TOP + 1]) Algorithm to obtain value of ith element from the top of the St ack: Function PEEP(S, TOP, I) TOP A pointer ( or index) pointing to the top element of stack S Array or Vector representing stack containing N elements I Index of element from T OP of the stack 1) [ Check for underflow on stack ] If TOP I then Write ( Stack Underflow on PEEP ) 2) [ Ith element from top of stack ] ( S[ TOP I + 1]) 1 / 4

2 Algorithm to change the content of ith element from the top of the Stack: Function CHANGE(S, TOP, X, I) TOP A pointer ( or index) pointing to the top element of stack S Array or Vector representing stack containing N elements I Index of element from T OP of the stack X Value of element to be change in the stack 1) [ Check for underflow on stack ] If TOP I then Write ( Stack Underflow on PEEP ) 2) [ Change Ith element from top of stack ] S[TOP I + 1] X 3) [ Finished ] Queue Algorithm to Insert an element in a Queue: Procedure QINSERT(Q, F, R, N, Y) Y Value of element to be inserted in queue F A pointer ( or index) pointing to the front element of queue R A pointer ( or index) pointing to the rear element of queue Q Array or Vector representing queue containing N elements This procedure insert Y at the rear of the queue. Prior to the first invocation of the procedure QINSERT, F and R have been set to zero. 1) [ Overflow? ] If R N then Write ( OVERFLOW ) 2) [ Increment rear pointer ] R R + 1 3) [ Insert element ] Q[R] Y 4) [ Is front pointer properly set? ] If F = 0 then F 1 Algorithm to Delete an element from a Queue: Function QDELETE(Q, F, R) F A pointer ( or index) pointing to the front element of queue R A pointer ( or index) pointing to the rear element of queue Q Array or Vector representing queue containing N elements 2 / 4

3 Y Temporary variable to store value of deleted element of queue This function deletes and return the front element of the queue 1) [ Underflow? ] If F = 0 then Write ( UNDERFLOW ) (0) 2) [ Delete element] Y Q[F] 3) [ Queue empty? ] If F = R then F R 0 else F F + 1 4) [ element ] (Y) Algorithm to Insert an element in a Ci rcular Queue: Procedure CQINSERT(F, R, Q, N, Y) Y Value of element to be inserted in queue F A pointer ( or index) pointing to the front element of queue R A pointer ( or index) pointing to the rear element of queue Q Array or Vector representing queue containing N elements This procedure insert Y at the rear of the que ue. Prior to the first invocation of the procedure CQINSERT, F and R have been set to zero. 1) [ Reset rear pointer? ] If R = N then R 1 else R R + 1 2) [ Overflow? ] If F = R then Write ( OVERFLOW ) 3) [ Insert element ] Q[R] Y 4) [ Is front pointer properly set? ] If F = 0 then F 1 Algorithm to Delete an element from a Circular Queue: Function CQDELETE(Q, F, R, N) F A pointer ( or index) pointing to the front element of queue R A pointer ( or index) pointing to the rear element of queue Q Array or Vector representing queue containing N elements 3 / 4

4 Y Temporary variable to store value of deleted element of queue This function deletes and return the front element of the queue 1) [ Underflow? ] If F = 0 then Write ( UNDERFLOW ) (0) 2) [ Delete element] Y Q[F] 3) [ Queue empty? ] If F = R then F R 0 (Y) 4) [ Increment front pointer ] If F = N then F 1 else F F +1 (Y) 4 / 4

5 Singly Linked List Algorithm to Insert New Node at the Beginning of the Linked List: Function INSERT(X, FIRST ): X Value of new element stored in I NFO part of newly created Node FIRST A pointer to the First Node of a Linked Linear List AVAIL A pointer to the top Node of the Free Node List NEW Temporary pointer pointing to newly created node Node contains INFO and LINK Fields 1) [ Underflow? Or Not Enough Memory] If AVAIL = NULL then Write ( Availability Stack Underflow ) ( FIRST) 2) [ Obtain address of next Free Node ] NEW AVAIL 3) [ Remove Free Node from availability stack ] AVAIL LINK (AVAIL) 4) [ Initialize fields of new Node and its link to the List ] INFO (NEW) X LINK (NEW) FIRST 5) [ address of new Node ] ( NEW) (Or FIRST NEW if we are not returning address from Function) When function INSERT is invoked, it returns a pointer value to the variable FIRST. i.e. FIRST INSERT(X, FIRST) Algorithm to Insert New Node at the End of the Linked List: Function INSEND(X, FIRST): X Value of new element stored in I NFO part of newly created Node FIRST A pointer to the First Node of a Linked Linear List AVAIL A pointer to the top Node of the Free Node List NEW Temporary pointer pointing to newly created node SAVE - Temporary pointer required for Traversing the List to reach the last Node Node contains INFO and LINK Fields 1) [ Underflow? Or Not Enough Memory] If AVAIL = NULL then Write ( Availability Stack Underflow ) ( FIRST) 2) [ Obtain address of next Free Node ] NEW AVAIL 3) [ Remove Free Node from availability stack ] AVAIL LINK (AVAIL) 4) [ Initialize fields of new Node and its link to the List ] INFO (NEW) X 1 / 4

6 LINK (NEW) NULL 5) [ Is the List empty ] If FIRST = NULL then ( NEW) 6) [ Initialize search for the Last Node ] SAVE FIRST 7) [ Search for End of the List ] Repeat while LINK ( SAVE) NULL SAVE LINK (SAVE) 8) [ Set LINK field of last Node to NEW ] LINK (SAVE) NEW 9) [ first Node pointer ] ( FIRST) When function INSE ND is invoked, it returns a pointer value to the variable FIRST. i.e. FIRST INSEND(X, FIRST) Algorithm to Insert New Node into an Ordered Linked List: Function INSORD(X, FIRST): X Value of new element stored in I NFO part of newly created Node FIRST A pointer to the First Node of a Linked Linear List AVAIL A pointer to the top Node of the Free Node List NEW Temporary pointer pointing to newly created node SAVE - Temporary pointer required for Traversing the List to reach the last Node Node contains INFO and LINK Fields 1) [ Underflow? Or Not Enough Memory] If AVAIL = NULL then Write ( Availability Stack Underflow ) ( FIRST) 2) [ Obtain address of next Free Node ] NEW AVAIL 3) [ Remove Free Node from availability stack ] AVAIL LINK (AVAIL) 4) [ Copy information contents into new Node ] INFO (NEW) X 5) [ Is the List empty ] If FIRST = NULL then LINK (NEW) NULL ( NEW) 6) [ Does the new Node precede all others in the List? ] If INFO (NEW) INFO (FIRST) then LINK (NEW) FIRST ( NEW) 7) [ Initialize temporary pointer ] 2 / 4

7 SAVE FIRST 8) [ Search for Predecessor of new Node ] Repeat while LINK (SAVE) NULL and INFO (LINK (SAVE)) INFO (NEW) SAVE LINK (SAVE) 9) [ Set LINK field of new Node and its Predecessor ] LINK ( NEW) LINK (SAVE) LINK (S AVE) NEW 10) [ first Node pointer ] ( FIRST) When function INS ORD is invoked, it returns a pointer value to the variable FIRST. i.e. FIRST INSORD(X, FIRST) Algorithm to Delete Node from Linked List: Procedure DELETE(X, FIRST): X A pointer to the Node in the Linked List, which we want to delete FIRST A pointer to the First Node of a Linked Linear List AVAIL A pointer to the top Node of the Free Node List TEMP Temporary pointer used to find the desired Node PRED - Pointer that keeps track of the predecessor of T EMP Node contains INFO and LINK Fields 1) [ Empty list?] If FIRST = NULL then Write ( Underflow ) 2) [ Initialize search for X ] TEMP FIRST 3) [ Find X ] Repeat thru step 5 while TEMP X and LINK ( TEMP) NULL 4) [ Update predecessor marker] PRED TEMP 5) [ Move to next Node ] TEMP LINK (TEMP) 6) [ End of the list ] If TEMP X then Write ( Node NOT Found ) 7) [ Delete X ] If X = FIRST ( Is X the first Node?) then FIRST LINK (FIRST) else LINK (PRED) LINK (X) 8) [ Node to availability stack ] LINK (X) AVAIL AVAIL X 3 / 4

8 FIRST is changed only when X is pointing to the first Node of the list. Procedure DELETE assumes that the address of the Node to be deleted is known initially. Algorithm to Copy Linked List: Function COPY(FIRST): FIRST A pointer to the First Node of a Linked Linear List, whose copy is made AVAIL A pointer to the top Node of the Free Node List BEGIN A pointer to the First Node of newly created Linked List NEW, PRED, SAVE Temporary pointers Existing Linked List Node contains INFO and LINK Fields New Linked List Node contains FIELD and PTR Fields 1) [ Empty list?] If FIRST = NULL then ( NULL) 2) [ Copy first node ] If AVAIL = NULL then Write ( Availa bility Stack Underflow ) ( 0) else NEW AVAIL AVAIL LINK (AVAIL) FIELD (NEW) INFO (FIRST) BEGIN NEW 3) [ Initialize traversal ] SAVE FIRST 4) [ Move to next node if not at end of list ] Repeat thru step 6 while LINK ( SAVE) NULL 5) [ Update predecessor and save pointers ] PRED NEW SAVE LINK (SAVE) 6) [ Copy node ] If AVAIL = NULL then Write ( Availability Stack Underflow ) (0) Else NEW AVAIL AVAIL LINK (AVAIL) FIELD (NEW) INFO (SAVE) PTR (PRED) NEW 7) [ Set link of last node and return ] PTR (NEW) NULL ( BEGIN) 4 / 4

9 Doubly Linked List Algorithm to Insert New Node to the left of a given Node in Doubly Linked Linear List: Procedure DOUBINS( L, R, M, X): X Value of new element stored in I NFO part of newly created Node L A pointer to the Left- most Node of a Linked Linear List R A pointer to the Right- most Node of a Linked Linear List M A pointer pointing to the Node, to the left new Node is inserted NEW Temporary pointer pointing to newly created node Node contains INFO, LPTR ( Left Link) and RPTR ( Right Link) Fields 1) [ Obtain New Node from availability Stack ] NEW <= NODE 2) [ Copy I nformation field ] INFO (NEW) X 3) [ Insertion into an empty List? ] If R = NULL then LPTR (NEW) RPTR (NEW) NULL L R NEW 4) [ Left- most I nsertion ] If M = L then LPTR (NEW) NULL RPTR (NEW) M LPTR (M) NEW L NEW 5) [ Insert in M iddle ] LPTR (NEW) LPTR (M) RPTR (NEW) M LPTR (M) NEW RPTR (LPTR (NEW)) NEW Algorithm to Delete a Node from Doubly Linked Linear List: Procedure DOUBDEL(L, R, OLD) L A pointer to the Left- most Node of a Linked Linear List R A pointer to the Right- most Node of a Linked Linear List OLD A pointer pointing to the Node to be deleted Node contains INFO, LPTR( Left Link) and RPTR( Right Link) Fields 1) [ Underflow? ] If R = NULL then Write( Underflow ) 1 / 2

10 2) [ Delete node ] If L = R ( Single Node in List) then L R NULL else If OLD = L ( Left- most Node being Deleted) then L RPTR (L) LPTR (L) NULL else If OLD = R ( Right- most Node being Deleted) then R LPTR (R) RPTR (R) NULL else RPTR (LPTR (OLD)) RPTR (OLD) LPTR (RPTR (OLD)) LPTR (OLD) 3) [ deleted Node ] Restore( OLD) 2 / 2

11 Tree Algorithm for a pre-order traversal of a binary tree (Iterative) Procedure PREORDER(T) : T A pointer to the Root Node of Binary Tree P A pointer pointing to the current node in the Tree S An auxiliary Stack used to store Node addresses TOP Top index of Stack Node contains DATA and two pointers LPTR and RPTR DATA Information associated with a Node LPTR A pointer to Left sub tree RPTR A pointer to Right sub tree 1) [ Initialize ] If T = NULL then Write( EMPTY TREE ) else TOP 0 Call PUSH( S, TOP, T) 2) [ Process each stacked branch address ] Repeat step 3 while TOP > 0 3) [ Get stored address and branch left ] P POP(S, TOP) Repeat while P NULL 4) [ Finished ] Write( DATA( P)) If RPTR( P) NULL then Call PUSH( S, TOP, RPTR( P)) [ P LPTR(P) [ branch left ] store address of nonempty right sub tree ] Algorithm for a post-order traversal of a binary tree (Iterative) Procedure POSTORDER(T): T A pointer to the Root Node of Binary Tree P A pointer pointing to the current node in the Tree S An auxiliary Stack used to store Node addresses TOP Top index of Stack Node contains DATA and two pointers LPTR and RPTR DATA Information associated with a Node LPTR A pointer to Left sub tree RPTR A pointer to Right sub tree 1) [ Initialize ] 1 / 5

12 If T = NULL then Write( EMPTY TREE ) else P T TOP 0 2) [ Traverse in post- order ] Repeat thru step 5 while true 3) [ Descend left ] Repeat while P NULL Call PUSH( S, TOP, P) P LPTR(P) 4) [ Process a node whose left and right sub trees have been traversed ] Repeat while S [ TOP] < 0 P POP(S, TOP) Write(DATA (P)) If TOP = 0 ( Have all nodes been processed? ) then 5) [ Branch right and then mark node from which we branched ] P RPTR(S[TOP]) S [TOP] -S[TOP] Algorithm for a pre-order traversal of a binary tree (Recursive) Procedure RPREORDER(T): T A pointer to the Root Node of Binary Tree Node contains DATA and two pointers LPTR and RPTR DATA Information associated with a Node LPTR A pointer to Left sub tree RPTR A pointer to Right sub tree 1) [ Process the root node ] If T NULL then Write( DATA( T)) else Write( EMPTY TREE ) 2) [ Process the left sub tree ] If LPTR( T) NULL then Call RPREORDER( LPTR( T)) 3) [ Process the right sub tree ] If RPTR( T) NULL then Call RPREORDER( RPTR( T)) 4) [ Finished ] 2 / 5

13 Algorithm for an in-order traversal of a binary tree (Recursive) Procedure RINORDER(T): T A pointer to the Root Node of Binary Tree Node contains DATA and two pointers LPTR and RPTR DATA Information associated with a Node LPTR A pointer to Left sub tree RPTR A pointer to Right sub tree 1) [ Check for empty tree ] If T = NULL then Write( EMPTY TREE ) 2) [ Process the left sub tree ] If LPTR( T) NULL then Call RINORDER( LPTR( T)) 3) [ Process the root node ] Write( DATA( T)) 4) [ Process the right sub tree ] If RPTR( T) NULL then Call RINORDER( RPTR( T)) 5) [ Finished ] Algorithm for a post-order traversal of a binary tree (Recursive) Procedure RPOSTORDER(T): T A pointer to the Root Node of Binary Tree Node contains DATA and two pointers LPTR and RPTR DATA Information associated with a Node LPTR A pointer to Left sub tree RPTR A pointer to Right sub tree 1) [ Check for empty tree ] If T = NULL then Write( EMPTY TREE ) 2) [ Process the left sub tree ] If LPTR( T) NULL then Call RPOSTORDER( LPTR( T)) 3) [ Process the right sub tree ] If RPTR( T) NULL then Call RPOSTORDER( RPTR( T)) 3 / 5

14 4) [ Process the root node ] Write( DATA( T)) 5) [ Finished ] Algorithm for deletion of a node from a lexically ordered binary tree Procedure TREE_DELETE(HEAD, X) : HEAD Address of tree X Information value ( DATA) of the node marked for deletion PARENT Pointer to the parent of the node marked for deletion CUR Address of the node to be deleted. PRED & SUC Pointers to find the inorder successor of CUR. Q Address of the node to which either the left or right link of the parent of X must be assigned in order to complete the deletion. D Direction from the parent node to the node marked for deletion. FOUND Boolean variable indicates whether the node marked for deletion has been found or not Node contains DATA and two pointers LPTR and RPTR DATA Information associated with a Node LPTR A pointer to Left sub tree RPTR A pointer to Right sub tree 1) [ Initialize ] If LPTR( HEAD) HEAD then CUR LPTR(HEAD) PARENT HEAD D L else Write( NODE NOT FOUND ) 2) [ Search for the node marked for deletion ] FOUND false Repeat while not FOUND AND CUR NULL If DATA( CUR) = X then FOUND true else If X < DATA( CUR) then ( branch left) PARENT CUR CUR LPTR(CUR) D L else ( branch right) PARENT CUR CUR RPTR(CUR) 4 / 5

15 D R If FOUND = false then Write( NODE NOT FOUND ) 3) [ Perform the indicated deletion and restructure the tree ] If LPTR( CUR) = NULL then ( empty left sub tree) Q RPTR(CUR) else If RPTR( CUR) = NULL then ( empty right sub tree) Q LPTR(CUR) else ( check right child for successor) SUC RPTR(CUR) If LPTR( SUC) = NULL then LPTR(SUC) LPTR(CUR) Q SUC else ( search for successor of CUR) PRED RPTR(CUR) SUC LPTR(PRED) Repeat while LPTR( SUC) NULL PRED SUC SUC LPTR(PRED) ( connect successor) LPTR(PRED) RPTR(SUC) LPTR(SUC) LPTR(CUR) RPTR(SUC) RPTR(CUR) Q SUC ( Connect parent of X to its replacement) If D = L then LPTR(PARENT) Q else RPTR(PARENT) Q 5 / 5

16 Sorting Algorithm for a Selection Sort Method Procedure SELECTION_SORT(K,N) : K Vector or Array to store elements N No of elements in Vector( or Array) K PASS Pass index or Pass counter MIN_INDEX Position of the smallest element in a particular pass I Index of Vector K 1) [ Loop on pass index ] Repeat thru step 4 for PASS = 1, 2,., N-1 2) [ Initialize minimum index ] MIN_INDEX PASS 3) [ Make a pass and obtain element with smallest value ] Repeat for I = PASS+1, PASS+2,.., N If K[ I] < K[ MIN_INDEX] then MIN_INDEX I 4) [ Exchange elements ] If MIN_INDEX PASS then K[PASS] K[MIN_INDEX] 5) [ Finished ] Algorithm for a Bubble Sort Method Procedure BUBBLE_SORT(K,N) : K Vector or Array to store elements N No of elements in Vector( or Array) K PASS Pass index or Pass counter LAST Indicate the position of the last unsorted element EXCHS Count the number of exchanges made on any pass I Index of Vector K 1) [ Initialize ] LAST N (entire list assumed unsorted at this position) 2) [ Loop on p ass index ] Repeat thru step 5 for PASS = 1, 2,.., N-1 3) [ Initialize exchanges counter for this pass ] EXCHS 0 4) [ Perform pair wise comparisons on unsorted elements ] Repeat for I = 1, 2,.., LAST-1 If K[I] > K[I+1] then K[I] K[I+1] EXCHS EXCHS / 5

17 5) [ Were any exchanges made on this pass? ] If EXCHS = 0 then ( sorting completed, return early) else LAST LAST - 1 (reduce size of unsorted list) 6) [ Finished ] ( maximum number of passes required) Algorithm for a Simple Merge Sort Method Procedure SIMPLE_MERGE(K, FIRST, SECOND, THIRD) : K Two ordered sub tables stored in Vector k( or Array) FIRST Start index of Table 1 ( Table 1 end at SECOND - 1) SECOND Start index of Table 2 THIRD End index of Table 2 TEMP Temporary Ve ctor use in merging process I Index of Table 1 J Index of Table 2 L Index of Vector TEMP 1) [ Initialize ] I FIRST J SECOND L 0 2) [ Compare corresponding elements and output the smallest ] Repeat while I < SECOND and J T HIRD If K[I] K[J] then L L + 1 TEMP[L] K[I] I I + 1 else L L + 1 TEMP[L] K[J] J J + 1 3) [ Copy the remaining unprocessed elements in output area ] If I SECOND then Repeat while J THIRD L L + 1 TEMP[L] K[J] J J + 1 else Repeat while I < SECOND L L + 1 TEMP[L] K[I] I I / 5

18 4) [ Copy elements in temporary vector into original area ] Repeat for I = 1, 2,.., L K[FIRST 1 + I] TEMP[I] 5) [ Finished ] Algorithm for a Quick Sort Method Procedure Quick_SORT(K, LB, UB) : K Vector or Array to store elements N No of elements in Vector( or Array) K LB Lower bound of the current sub table being processed. UB Upper bound of the current sub table being processed. I & J Indices used to select certain keys during the process ing of each sub table. KEY Key value which is being placed in its final position within the sorted subtable. FLAG Logical variable which indicates the end of the process that places a record in its final position. 1) [ Initialize ] FLAG true 2) [ Perform sort ] If LB < UB then I LB J UB + 1 KEY K[LB] Repeat while FLAG I I + 1 Repeat while K[ I] < KEY ( scan the keys from left to right) I I + 1 J J 1 Repeat while K[ J] > KEY ( scan the keys from right to left) J J 1 If I < J then K[I] K[J] (interchange records) else FLAG false K[LB] K[J] (interchange records) Call QUICK_SORT( K, LB, J 1) ( sort first sub table) Call QUICK_SORT( K, J+1, UB) ( sort second sub table) 3) [ Finished ] 3 / 5

19 Searching Algorithm for a Linear(or Sequential) Search Method Function LINEAR_SEARCH(K, N, X) : K Unordered Vector consisting of N+1 element N Number of elements in Vector K X Value of element to be searched K[ N+1] Vector element serves as a sentinel element and receives the value of X prior to the search This function returns the index of the vector element if the search is successful, and returns 0 otherwise 1) [ Initialize search ] I 1 K[N+1] X 2) [ Search the vector ] Repeat while K[ I] X I I + 1 3) [ Successful search? ] If I = N+1 then Write( UNSUCCESSFUL SEARCH ) ( 0) else Write( SUCCESSFUL SEARCH ) ( I) Algorithm for a Binary Search Method(Iterative) Function BINARY_SEARCH(K, N, X) : K Vector K, consisting of N element s in ascending order N Number of elements in Vector K X Value of element to be searched LOW Lower index of the search interval MIDDLE M iddle index of the search interval HIGH Upper inde x of the search interval This function returns the index of the vector element if the search is successful, and returns 0 otherwise 1) [ Initialize search ] LOW 1 HIGH N 2) [ Perform search ] Repeat thru step 4 while LOW HIGH 3) [ Obtain index of midpoint of interval ] 4 / 5

20 MIDDLE (LOW + HIGH) / 2 4) [ Compare ] If X < K[ MIDDLE] then HIGH MIDDLE 1 else If X > K[ MIDDLE] then LOW MIDDLE + 1 else Write( SUCCESSFUL SEARCH ) ( MIDDLE) 5) [ Unsuccessful search ] Write( SUCCESSFUL SEARCH ) ( 0) Algorithm for a Binary Search Method(Recursive) Function BINARY_SEARCH_R(P, Q, K, X) : K Vector K, consisting of N elements in ascending order N Number of elements in Vector K X Value of element to be searched LOC Stores the index of the search element MIDDLE M iddle index of the search interval P & Q Bounds of a sub table This function returns the index of the vector element if the search is successful, and returns 0 otherwise 1) [ Search vector K between P and Q for value X ] If P > Q then LOC 0 else MIDDLE (P + Q) / 2 If X < K[ MIDDLE] then LOC BINARY_SEARCH_R(P, MIDDLE -1, K, X) else If X > K[ MIDDLE] then LOC BINARY_SEARCH_R(MIDDLE+1, Q, K, X) else LOC MIDDLE 2) [ Finished ] ( LOC) With initial call POSITION BINARY_SEARCH_R( 1, N, K, X) 5 / 5

The time and space are the two measure for efficiency of an algorithm.

The time and space are the two measure for efficiency of an algorithm. There are basically six operations: 5. Sorting: Arranging the elements of list in an order (either ascending or descending). 6. Merging: combining the two list into one list. Algorithm: The time and space

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE TED (10)-3071 Reg. No.. (REVISION-2010) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours (Maximum marks: 100)

More information

Insert. SEMCOM Page 1 of 11

Insert. SEMCOM Page 1 of 11 CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar Faculty Name: Ami D. Trivedi Class: FYBCA Subject: US02CBCA01 (Advanced C Programming and Introduction to Data Structures) *UNIT 4 (Some More Data structures

More information

1 P age DS & OOPS / UNIT II

1 P age DS & OOPS / UNIT II UNIT II Stacks: Definition operations - applications of stack. Queues: Definition - operations Priority queues - De que Applications of queue. Linked List: Singly Linked List, Doubly Linked List, Circular

More information

Introduction to Data Structure

Introduction to Data Structure Introduction to Data Structure Introduction to Data Structure Computer is an electronic machine which is used for data processing and manipulation. When programmer collects such type of data for processing,

More information

Fundamentals of Data Structure

Fundamentals of Data Structure Fundamentals of Data Structure Set-1 1. Which if the following is/are the levels of implementation of data structure A) Abstract level B) Application level C) Implementation level D) All of the above 2.

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may

More information

Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113)

Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113) Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113) 1. The number of interchanges required to sort 5, 1, 6, 2 4 in ascending order using Bubble Sort (A)

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours TED (10)-3071 Reg. No.. (REVISION-2010) (Maximum marks: 100) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours PART

More information

Sample Question Paper

Sample Question Paper Scheme - I Sample Question Paper Marks : 70 Time: 3 Hrs. Q.1) Attempt any FIVE of the following. 10 Marks a. Write any four applications of data structure. b. Sketch the diagram of circular queue. c. State

More information

Department of Computer Science and Technology

Department of Computer Science and Technology UNIT : Stack & Queue Short Questions 1 1 1 1 1 1 1 1 20) 2 What is the difference between Data and Information? Define Data, Information, and Data Structure. List the primitive data structure. List the

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 18 EXAMINATION Subject Name: Data Structure Model wer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in

More information

DATA STRUCTURES/UNIT 3

DATA STRUCTURES/UNIT 3 UNIT III SORTING AND SEARCHING 9 General Background Exchange sorts Selection and Tree Sorting Insertion Sorts Merge and Radix Sorts Basic Search Techniques Tree Searching General Search Trees- Hashing.

More information

Answers. 1. (A) Attempt any five : 20 Marks

Answers. 1. (A) Attempt any five : 20 Marks Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate

More information

Operations on Heap Tree The major operations required to be performed on a heap tree are Insertion, Deletion, and Merging.

Operations on Heap Tree The major operations required to be performed on a heap tree are Insertion, Deletion, and Merging. Priority Queue, Heap and Heap Sort In this time, we will study Priority queue, heap and heap sort. Heap is a data structure, which permits one to insert elements into a set and also to find the largest

More information

DATA STRUCTURES AND ALGORITHMS

DATA STRUCTURES AND ALGORITHMS DATA STRUCTURES AND ALGORITHMS For COMPUTER SCIENCE DATA STRUCTURES &. ALGORITHMS SYLLABUS Programming and Data Structures: Programming in C. Recursion. Arrays, stacks, queues, linked lists, trees, binary

More information

O(n): printing a list of n items to the screen, looking at each item once.

O(n): printing a list of n items to the screen, looking at each item once. UNIT IV Sorting: O notation efficiency of sorting bubble sort quick sort selection sort heap sort insertion sort shell sort merge sort radix sort. O NOTATION BIG OH (O) NOTATION Big oh : the function f(n)=o(g(n))

More information

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305 Q.1 If h is any hashing function and is used to hash n keys in to a table of size m, where n

More information

6-TREE. Tree: Directed Tree: A directed tree is an acyclic digraph which has one node called the root node

6-TREE. Tree: Directed Tree: A directed tree is an acyclic digraph which has one node called the root node 6-TREE Data Structure Management (330701) Tree: A tree is defined as a finite set of one or more nodes such that There is a special node called the root node R. The remaining nodes are divided into n 0

More information

3. Fundamental Data Structures

3. Fundamental Data Structures 3. Fundamental Data Structures CH08-320201: Algorithms and Data Structures 233 Data Structures Definition (recall): A data structure is a way to store and organize data in order to facilitate access and

More information

CSCE 2014 Final Exam Spring Version A

CSCE 2014 Final Exam Spring Version A CSCE 2014 Final Exam Spring 2017 Version A Student Name: Student UAID: Instructions: This is a two-hour exam. Students are allowed one 8.5 by 11 page of study notes. Calculators, cell phones and computers

More information

Final Exam Data Structure course. No. of Branches (5)

Final Exam Data Structure course. No. of Branches (5) Page ١of 5 College Of Science and Technology Khan younis - Palestine Computer Science & Inf. Tech. Information Technology Data Structure (Theoretical Part) Time: 2 Hours Name: ID: Mark: Teacher 50 Mahmoud

More information

CS301 - Data Structures Glossary By

CS301 - Data Structures Glossary By CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 17 EXAMINATION Subject Name: Data Structure Using C Model Answer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 18 EXAMINATION Subject Name: Data Structure using C Model wer Subject Code: 22317 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given

More information

a) State the need of data structure. Write the operations performed using data structures.

a) State the need of data structure. Write the operations performed using data structures. Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate

More information

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech

More information

CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar

CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar Faculty Name: Ami D. Trivedi Class: FYBCA Subject: US02CBCA01 (Advanced C Programming and Introduction to Data Structures) *UNIT 3 (Introduction to Data

More information

CS 8391 DATA STRUCTURES

CS 8391 DATA STRUCTURES DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK CS 8391 DATA STRUCTURES UNIT- I PART A 1. Define: data structure. A data structure is a way of storing and organizing data in the memory for

More information

Basic Data Structures (Version 7) Name:

Basic Data Structures (Version 7) Name: Prerequisite Concepts for Analysis of Algorithms Basic Data Structures (Version 7) Name: Email: Concept: mathematics notation 1. log 2 n is: Code: 21481 (A) o(log 10 n) (B) ω(log 10 n) (C) Θ(log 10 n)

More information

Ashish Gupta, Data JUET, Guna

Ashish Gupta, Data JUET, Guna Categories of data structures Data structures are categories in two classes 1. Linear data structure: - organized into sequential fashion - elements are attached one after another - easy to implement because

More information

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM

More information

Abstract Data Structures IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

Abstract Data Structures IB Computer Science. Content developed by Dartford Grammar School Computer Science Department Abstract Data Structures IB Computer Science Content developed by Dartford Grammar School Computer Science Department HL Topics 1-7, D1-4 1: System design 2: Computer Organisation 3: Networks 4: Computational

More information

CS8391-DATA STRUCTURES QUESTION BANK UNIT I

CS8391-DATA STRUCTURES QUESTION BANK UNIT I CS8391-DATA STRUCTURES QUESTION BANK UNIT I 2MARKS 1.Define data structure. The data structure can be defined as the collection of elements and all the possible operations which are required for those

More information

18.3 Deleting a key from a B-tree

18.3 Deleting a key from a B-tree 18.3 Deleting a key from a B-tree B-TREE-DELETE deletes the key from the subtree rooted at We design it to guarantee that whenever it calls itself recursively on a node, the number of keys in is at least

More information

17CS33:Data Structures Using C QUESTION BANK

17CS33:Data Structures Using C QUESTION BANK 17CS33:Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C Learn : Usage of structures, unions - a conventional tool for handling a group of logically

More information

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions

More information

Binary Trees. Height 1

Binary Trees. Height 1 Binary Trees Definitions A tree is a finite set of one or more nodes that shows parent-child relationship such that There is a special node called root Remaining nodes are portioned into subsets T1,T2,T3.

More information

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web:     Ph: Serial : 1PT_CS_A+C_Programming & Data Structure_230918 Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: E-mail: info@madeeasy.in Ph: 011-45124612 CLASS TEST 2018-19

More information

Trees. (Trees) Data Structures and Programming Spring / 28

Trees. (Trees) Data Structures and Programming Spring / 28 Trees (Trees) Data Structures and Programming Spring 2018 1 / 28 Trees A tree is a collection of nodes, which can be empty (recursive definition) If not empty, a tree consists of a distinguished node r

More information

CS DATA STRUCTURES AND ALGORITHMS

CS DATA STRUCTURES AND ALGORITHMS Computer Science and Engineering Third Semester CS1211 - DATA STRUCTURES AND ALGORITHMS UNIT-I - INTRODUCTION TO DATASTRUCTURES 1.Write down the definition of data structures? PART -A A data structure

More information

DDS Dynamic Search Trees

DDS Dynamic Search Trees DDS Dynamic Search Trees 1 Data structures l A data structure models some abstract object. It implements a number of operations on this object, which usually can be classified into l creation and deletion

More information

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we should Use better data structures

More information

CSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1

CSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1 CSE 2100 Data Structures and Introduction to Algorithms...! In Java!! Instructor: Fei Wang! Mid-Term Exam CSE2100 DS & Algorithms 1 1. True or False (20%=2%x10)! (1) O(n) is O(n^2) (2) The height h of

More information

Data Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved.

Data Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved. Data Structures Outline Introduction Linked Lists Stacks Queues Trees Introduction dynamic data structures - grow and shrink during execution Linked lists - insertions and removals made anywhere Stacks

More information

1. Two main measures for the efficiency of an algorithm are a. Processor and memory b. Complexity and capacity c. Time and space d.

1. Two main measures for the efficiency of an algorithm are a. Processor and memory b. Complexity and capacity c. Time and space d. 1. Two main measures for the efficiency of an algorithm are a. Processor and memory b. Complexity and capacity c. Time and space d. Data and space 2. The time factor when determining the efficiency of

More information

CS8391-DATA STRUCTURES

CS8391-DATA STRUCTURES ST.JOSEPH COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERI NG CS8391-DATA STRUCTURES QUESTION BANK UNIT I 2MARKS 1.Explain the term data structure. The data structure can be defined

More information

Cpt S 122 Data Structures. Sorting

Cpt S 122 Data Structures. Sorting Cpt S 122 Data Structures Sorting Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Sorting Process of re-arranging data in ascending or descending order Given

More information

University of Palestine. Final Exam 2 nd semester 2014/2015 Total Grade: 50

University of Palestine. Final Exam 2 nd semester 2014/2015 Total Grade: 50 First Question Q1 B1 Choose the best Answer: No. of Branches (1) (10/50) 1) 2) 3) 4) Suppose we start with an empty stack and then perform the following operations: Push (A); Push (B); Pop; Push (C); Top;

More information

Data Structure. IBPS SO (IT- Officer) Exam 2017

Data Structure. IBPS SO (IT- Officer) Exam 2017 Data Structure IBPS SO (IT- Officer) Exam 2017 Data Structure: In computer science, a data structure is a way of storing and organizing data in a computer s memory so that it can be used efficiently. Data

More information

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.) CSE 0 Name Test Spring 006 Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose f ( x) is a monotonically increasing function. Which of the

More information

Sorting and Searching

Sorting and Searching Sorting and Searching Lecture 2: Priority Queues, Heaps, and Heapsort Lecture 2: Priority Queues, Heaps, and Heapsort Sorting and Searching 1 / 24 Priority Queue: Motivating Example 3 jobs have been submitted

More information

V Advanced Data Structures

V Advanced Data Structures V Advanced Data Structures B-Trees Fibonacci Heaps 18 B-Trees B-trees are similar to RBTs, but they are better at minimizing disk I/O operations Many database systems use B-trees, or variants of them,

More information

MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Subject Code: 17330 Model Answer Page 1/ 22 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model

More information

Summer Final Exam Review Session August 5, 2009

Summer Final Exam Review Session August 5, 2009 15-111 Summer 2 2009 Final Exam Review Session August 5, 2009 Exam Notes The exam is from 10:30 to 1:30 PM in Wean Hall 5419A. The exam will be primarily conceptual. The major emphasis is on understanding

More information

Data Structures and Algorithms Notes

Data Structures and Algorithms Notes Data Structures and Algorithms Notes Notes by Winst Course taught by Dr. G. R. Baliga 256-400 ext. 3890 baliga@rowan.edu Course started: September 4, 2012 Last generated: December 18, 2013 Interfaces -

More information

We have the pointers reference the next node in an inorder traversal; called threads

We have the pointers reference the next node in an inorder traversal; called threads Leaning Objective: In this Module you will be learning the following: Threaded Binary Tree Introduction: Threaded Binary Tree is also a binary tree in which all left child pointers that are NULL (in Linked

More information

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs Computational Optimization ISE 407 Lecture 16 Dr. Ted Ralphs ISE 407 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms in

More information

Abstract Data Types CHAPTER 12. Review Questions

Abstract Data Types CHAPTER 12. Review Questions PTR bstract ata Types Review Questions. n abstract data type is a data declaration packaged together with the operations that are meaningful for the data type with the implementation hidden from the user..

More information

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n) CSE 0 Test Your name as it appears on your UTA ID Card Fall 0 Multiple Choice:. Write the letter of your answer on the line ) to the LEFT of each problem.. CIRCLED ANSWERS DO NOT COUNT.. points each. The

More information

Sorting and Searching

Sorting and Searching Sorting and Searching Lecture 2: Priority Queues, Heaps, and Heapsort Lecture 2: Priority Queues, Heaps, and Heapsort Sorting and Searching 1 / 24 Priority Queue: Motivating Example 3 jobs have been submitted

More information

V Advanced Data Structures

V Advanced Data Structures V Advanced Data Structures B-Trees Fibonacci Heaps 18 B-Trees B-trees are similar to RBTs, but they are better at minimizing disk I/O operations Many database systems use B-trees, or variants of them,

More information

( D. Θ n. ( ) f n ( ) D. Ο%

( D. Θ n. ( ) f n ( ) D. Ο% CSE 0 Name Test Spring 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to run the code below is in: for i=n; i>=; i--) for j=; j

More information

MLR Institute of Technology

MLR Institute of Technology MLR Institute of Technology Laxma Reddy Avenue, Dundigal, Quthbullapur (M), Hyderabad 500 043 Phone Nos: 08418 204066 / 204088, Fax : 08418 204088 TUTORIAL QUESTION BANK Course Name : DATA STRUCTURES Course

More information

An Introduction to Trees

An Introduction to Trees An Introduction to Trees Alice E. Fischer Spring 2017 Alice E. Fischer An Introduction to Trees... 1/34 Spring 2017 1 / 34 Outline 1 Trees the Abstraction Definitions 2 Expression Trees 3 Binary Search

More information

Dynamic Data Structures

Dynamic Data Structures Dynamic Data Structures We have seen that the STL containers vector, deque, list, set and map can grow and shrink dynamically. We now examine how some of these containers can be implemented in C++. To

More information

B-Trees. Disk Storage. What is a multiway tree? What is a B-tree? Why B-trees? Insertion in a B-tree. Deletion in a B-tree

B-Trees. Disk Storage. What is a multiway tree? What is a B-tree? Why B-trees? Insertion in a B-tree. Deletion in a B-tree B-Trees Disk Storage What is a multiway tree? What is a B-tree? Why B-trees? Insertion in a B-tree Deletion in a B-tree Disk Storage Data is stored on disk (i.e., secondary memory) in blocks. A block is

More information

(2,4) Trees. 2/22/2006 (2,4) Trees 1

(2,4) Trees. 2/22/2006 (2,4) Trees 1 (2,4) Trees 9 2 5 7 10 14 2/22/2006 (2,4) Trees 1 Outline and Reading Multi-way search tree ( 10.4.1) Definition Search (2,4) tree ( 10.4.2) Definition Search Insertion Deletion Comparison of dictionary

More information

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE A6-R3: DATA STRUCTURE THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered in the TEAR-OFF

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms CS245-2017S-06 Binary Search Trees David Galles Department of Computer Science University of San Francisco 06-0: Ordered List ADT Operations: Insert an element in the list

More information

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each CSE 0-00 Test Spring 0 Name Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose f ( x) is a monotonically increasing function. Which of the

More information

Solution: The examples of stack application are reverse a string, post fix evaluation, infix to postfix conversion.

Solution: The examples of stack application are reverse a string, post fix evaluation, infix to postfix conversion. 1. What is the full form of LIFO? The full form of LIFO is Last In First Out. 2. Give some examples for stack application. The examples of stack application are reverse a string, post fix evaluation, infix

More information

Data Structures. Alice E. Fischer. Lecture 4, Fall Alice E. Fischer Data Structures L4... 1/19 Lecture 4, Fall / 19

Data Structures. Alice E. Fischer. Lecture 4, Fall Alice E. Fischer Data Structures L4... 1/19 Lecture 4, Fall / 19 Data Structures Alice E. Fischer Lecture 4, Fall 2018 Alice E. Fischer Data Structures L4... 1/19 Lecture 4, Fall 2018 1 / 19 Outline 1 Ordered Lists 2 Sorted Lists Tail Pointers 3 Doubly Linked Lists

More information

12 Abstract Data Types

12 Abstract Data Types 12 Abstract Data Types 12.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT). Define

More information

UNIT IV 4 LINKED LIST

UNIT IV 4 LINKED LIST 4 UNIT IV LINKED LIST LINKED LIST SYLLABUS: 4.1 Pointers Revision 4.2 Revision of Structure 4.3 Revision of structure using pointers 4.4 Dynamic Memory Allocation 4.5 Linked list Presentation 4.6 Types

More information

DATA STRUCTURE UNIT I

DATA STRUCTURE UNIT I DATA STRUCTURE UNIT I 1. What is Data Structure? A data structure is a mathematical or logical way of organizing data in the memory that consider not only the items stored but also the relationship to

More information

Component 02. Algorithms and programming. Sorting Algorithms and Searching Algorithms. Matthew Robinson

Component 02. Algorithms and programming. Sorting Algorithms and Searching Algorithms. Matthew Robinson Component 02 Algorithms and programming Sorting Algorithms and Searching Algorithms 1 BUBBLE SORT Bubble sort is a brute force and iterative sorting algorithm where each adjacent item in the array is compared.

More information

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

& ( D.  mnp ' ( ) n 3. n 2. ( ) C.  n CSE Name Test Summer Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply two n " n matrices is: A. " n C. "% n B. " max( m,n, p). The

More information

Linked List. April 2, 2007 Programming and Data Structure 1

Linked List. April 2, 2007 Programming and Data Structure 1 Linked List April 2, 2007 Programming and Data Structure 1 Introduction head A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element

More information

Lecture Notes CPSC 122 (Fall 2014) Today Quiz 7 Doubly Linked Lists (Unsorted) List ADT Assignments Program 8 and Reading 6 out S.

Lecture Notes CPSC 122 (Fall 2014) Today Quiz 7 Doubly Linked Lists (Unsorted) List ADT Assignments Program 8 and Reading 6 out S. Today Quiz 7 Doubly Linked Lists (Unsorted) List ADT Assignments Program 8 and Reading 6 out S. Bowers 1 of 11 Doubly Linked Lists Each node has both a next and a prev pointer head \ v1 v2 v3 \ tail struct

More information

Search Trees - 1 Venkatanatha Sarma Y

Search Trees - 1 Venkatanatha Sarma Y Search Trees - 1 Lecture delivered by: Venkatanatha Sarma Y Assistant Professor MSRSAS-Bangalore 11 Objectives To introduce, discuss and analyse the different ways to realise balanced Binary Search Trees

More information

( ) ( ) C. " 1 n. ( ) $ f n. ( ) B. " log( n! ) ( ) and that you already know ( ) ( ) " % g( n) ( ) " #&

( ) ( ) C.  1 n. ( ) $ f n. ( ) B.  log( n! ) ( ) and that you already know ( ) ( )  % g( n) ( )  #& CSE 0 Name Test Summer 008 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time for the following code is in which set? for (i=0; i

More information

Priority Queues 1 / 15

Priority Queues 1 / 15 Priority Queues 1 / 15 Outline 1 API 2 Elementary Implementations 3 Heap Definitions 4 Algorithms on Heaps 5 Heap Sort 6 Heap Sort and Other Sorts 2 / 15 API Many applications require that we process items

More information

DC54 DATA STRUCTURES DEC 2014

DC54 DATA STRUCTURES DEC 2014 Q.2 a. Write a function that computes x^y using Recursion. The property that x^y is simply a product of x and x^(y-1 ). For example, 5^4= 5 * 5^3. The recursive definition of x^y can be represented as

More information

CS24 Week 8 Lecture 1

CS24 Week 8 Lecture 1 CS24 Week 8 Lecture 1 Kyle Dewey Overview Tree terminology Tree traversals Implementation (if time) Terminology Node The most basic component of a tree - the squares Edge The connections between nodes

More information

Chapter 17 Indexing Structures for Files and Physical Database Design

Chapter 17 Indexing Structures for Files and Physical Database Design Chapter 17 Indexing Structures for Files and Physical Database Design We assume that a file already exists with some primary organization unordered, ordered or hash. The index provides alternate ways to

More information

Lecture 6 Sorting and Searching

Lecture 6 Sorting and Searching Lecture 6 Sorting and Searching Sorting takes an unordered collection and makes it an ordered one. 1 2 3 4 5 6 77 42 35 12 101 5 1 2 3 4 5 6 5 12 35 42 77 101 There are many algorithms for sorting a list

More information

Draw a diagram of an empty circular queue and describe it to the reader.

Draw a diagram of an empty circular queue and describe it to the reader. 1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 1 1983/84 COSC1020/30 Tests >>> The following was given to students. >>> Students can have a good idea of test questions by examining and trying the

More information

Module 04 Trees Contents

Module 04 Trees Contents Module 04 Trees Contents Chethan Raj C Assistant Professor Dept. of CSE 1. Trees Terminology 2. Binary Trees, Properties of Binary trees 3. Array and linked Representation of Binary Trees 4. Binary Tree

More information

Data Structure Advanced

Data Structure Advanced Data Structure Advanced 1. Is it possible to find a loop in a Linked list? a. Possilbe at O(n) b. Not possible c. Possible at O(n^2) only d. Depends on the position of loop Solution: a. Possible at O(n)

More information

Lecture 6: Analysis of Algorithms (CS )

Lecture 6: Analysis of Algorithms (CS ) Lecture 6: Analysis of Algorithms (CS583-002) Amarda Shehu October 08, 2014 1 Outline of Today s Class 2 Traversals Querying Insertion and Deletion Sorting with BSTs 3 Red-black Trees Height of a Red-black

More information

[ DATA STRUCTURES ] Fig. (1) : A Tree

[ DATA STRUCTURES ] Fig. (1) : A Tree [ DATA STRUCTURES ] Chapter - 07 : Trees A Tree is a non-linear data structure in which items are arranged in a sorted sequence. It is used to represent hierarchical relationship existing amongst several

More information

DEEPIKA KAMBOJ UNIT 2. What is Stack?

DEEPIKA KAMBOJ UNIT 2. What is Stack? What is Stack? UNIT 2 Stack is an important data structure which stores its elements in an ordered manner. You must have seen a pile of plates where one plate is placed on top of another. Now, when you

More information

CSE 230 Intermediate Programming in C and C++

CSE 230 Intermediate Programming in C and C++ CSE 230 Intermediate Programming in C and C++ Structures and List Processing Fall 2017 Stony Brook University Instructor: Shebuti Rayana http://www3.cs.stonybrook.edu/~cse230/ Self-referential Structure

More information

2 Marks Questions & Answers

2 Marks Questions & Answers UNIT-I 2 Marks Questions & Answers 1. Define Data structures? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge

More information

CMSC351 - Fall 2014, Homework #2

CMSC351 - Fall 2014, Homework #2 CMSC351 - Fall 2014, Homework #2 Due: October 8th at the start of class Name: Section: Grades depend on neatness and clarity. Write your answers with enough detail about your approach and concepts used,

More information

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs Algorithms in Systems Engineering ISE 172 Lecture 16 Dr. Ted Ralphs ISE 172 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms

More information

Prepared By: Ms. Nidhi Solanki (Assist. Prof.) Page 1

Prepared By: Ms. Nidhi Solanki (Assist. Prof.) Page 1 QUESTION BANK ON COURSE: 304: PRELIMINARIES: 1. What is array of pointer, explain with appropriate example? 2 2. Differentiate between call by value and call by reference, give example. 3. Explain pointer

More information

MODULE 3: LINKED LIST

MODULE 3: LINKED LIST MODULE 3: LINKED LIST DEFINITION A linked list, or one-way list, is a linear collection of data elements, called nodes, where the linear order is given by means of pointers. That is, each node is divided

More information

(2,4) Trees Goodrich, Tamassia (2,4) Trees 1

(2,4) Trees Goodrich, Tamassia (2,4) Trees 1 (2,4) Trees 9 2 5 7 10 14 2004 Goodrich, Tamassia (2,4) Trees 1 Multi-Way Search Tree A multi-way search tree is an ordered tree such that Each internal node has at least two children and stores d -1 key-element

More information