Data Structures Through C. Student Workbook

Size: px
Start display at page:

Download "Data Structures Through C. Student Workbook"

Transcription

1 Data Structures Through C Student Workbook

2 Contents Lecture 1: C Revision I 01 Importance of data structures Data types in C Instructions and its types The decision control instruction Working of logical operators Different types of loops Difference between break, continue and exit Case control instruction Lecture 2: C Revision II 03 Pointers and their usage Function call by value and by reference Arrays and their working Lecture 3: Searching 05 Operations performed on an array What are algorithms Important features of an algorithm Conventions to be followed while writing an algorithm Linear search and Binary search Lecture 4: Searching and Frequency count 07 Analyzing an algorithm Rate of increase for growth rate with respect to Big Oh notation Lecture 5: Analysis of Searching Method 09 Tools to calculate time complexity Cases to be considered while analyzing an algorithm Analysis of Linear search and Binary search Lecture 6: Hashing 11 Hashing techniques: o Division method o Mid-Square method o Folding method o Digit analysis method Linear and Quadratic probing i

3 Lecture 7: Sorting 13 Selection sort and its analysis Bubble sort and its analysis Radix sort Lecture 8: Sorting and Recursion 15 Insertion sort Recursive functions Lecture 9: Quick Sort 17 Splitting mechanism Quick sort algorithm Quick sort program Lecture 10: Structures 19 Defining and using structures Array of structures Copying structure variables Nested structures Passing structure elements Passing structures Lecture 11: Structures and Polynomials 21 Polynomial representation Passing array of structures General operations on polynomials Lecture 12: Two Dimensional Arrays 23 Using two dimensional arrays Saddle point of an array Lecture 13: Sparse Matrices 25 Sparse matrices Passing arrays 3 tuple conversion Lecture 14: Transpose of Sparse Matrices 27 Transpose of a sparse matrix Lecture 15: Addition of Sparse Matrices 29 Addition of sparse matrices Lecture 16: Multiplication of Sparse Matrices 31 Matrix multiplication ii

4 Multiplication of sparse matrices Lecture 17: Storage 33 Storage - two dimensional arrays 3 dimensional arrays 4 dimensional arrays n - dimensional arrays Lecture 18: Dynamic memory allocation 35 Limitations of arrays Dynamic memory allocation Steps involved in memory allocation Lecture 19: Linked Lists 37 Memory leaks Linked lists Creation of linked lists Lecture 20: Operations on Linked Lists I 39 Appending a new node to a link list Adding a new node at the beginning of a linked list Adding a new node at a specified position in a linked list Deleting a node from a linked list Deleting all the nodes in a list Lecture 21: Operations on Linked Lists II 41 Arranging the elements in a linked list in ascending order Sorting the elements in a linked list Lecture 22: Operations on Linked Lists III 43 Reversing a linked list Merging two linked lists Lecture 23: Operations on Linked Lists IV 45 Concatenating two linked lists Addition of polynomials using linked lists Lecture 24: Circular Linked Lists 47 Circular linked lists Adding a new node to a circular list Deleting an existing node from a circular list Counting the nodes of a circular linked list Displaying the nodes in a circular linked list iii

5 Lecture 25: Doubly Linked Lists 49 Doubly linked lists Common operations on a doubly linked list Lecture 26: Sparse Matrices as Linked Lists I 51 Representing sparse matrices in the form of linked lists Lecture 27: Sparse Matrices as Linked Lists II 53 Add new node to linked Lists Display contents of Linked List Delete all nodes in the Linked List Program to implement sparse matrices as linked lists Lecture 28: Recursive LL 55 Recursive count( ) Recursive compare( ) Recursive copy( ) Recursive append( ) Lecture 29: Linked Lists Using Unions 57 What are unions Declaring unions Using unions Generalized linked lists Lecture 30: Generalized Linked Lists 59 Copying generalized linked lists Depth of generalized linked lists Comparing generalized linked lists Lecture 31: Stacks 61 Stack and its utilities Program to implement stack as an array Lecture 32: Stack as a Linked List 63 Program to implement stack as a linked list Lecture 33: Stack Expressions 65 Different form of expressions Lecture 34: Stack Operations 67 Infix to Postfix conversion Lecture 35: Postfix 69 Evaluation of Postfix form iv

6 Lecture 36: Infix To Prefix 71 Infix to Prefix conversion Lecture 37: Postfix To Prefix 73 Evaluation of Prefix form Postfix to Prefix conversion Lecture 38: Postfix To Infix 75 Postfix to Infix conversion Lecture 39: More Conversions 77 Prefix to Postfix conversion Prefix to Infix conversion Lecture 40: Queue I 79 Queue Program to implement queue as an array Lecture 41: Queue II 81 Limitations of queue Circular queue Lecture 42: Deque and Priority Queue 83 Deque Program to implement deque Priority queue Lecture 43: Trees 85 What are trees Tree terminology Strictly and complete trees Lecture 44: Tree Traversal 87 Preorder, Postorder and Inorder traversal Reconstruction of trees Lecture 45: Binary Search Trees I 89 Representing trees using arrays Linked representation of trees Binary search trees Lecture 46: Binary Search Trees II 91 Traversing of trees using Inorder, Preorder and Postorder Non recursive Inorder traversal of trees Non recursive Preorder traversal of trees v

7 Non recursive Postorder traversal of trees Comparison of two trees Lecture 47: Binary Tree 93 Successor and predecessor Insertion of a node in a binary search tree Deleting an existing node from a binary search tree Searching a node in a binary search tree Lecture 48: Threaded Binary Tree 95 Threaded binary trees Representation of threaded binary trees Inserting a node in a threaded binary tree Traversing the threaded binary tree in inorder Lecture 49: Heap 97 Heap Creation of a heap Heap sort Lecture 50: AVL Trees and B Tree 99 Program to create a heap AVL tree 2-3 tree B tree Lecture 51: Graphs 101 Graphs Terminology associated with graphs Representation of graphs Adjacency list Lecture 52: Adjacency Multilist 103 Adjacency matrices Adjacency multilist Orthogonal representation of graphs Lecture 53: Depth First Search 105 Depth first search Program to implement depth first search algorithm Lecture 54: Breadth First Search 107 Breadth first search vi

8 Program to implement breadth first search algorithm Lecture 55: Spanning Tree 109 What is a spanning tree Cost of spanning tree Kruskal s algorithm to determine minimum cost spanning tree Lecture 56: Dijkstra s Algorithm 111 Dijkstra s algorithm to determine minimum cost spanning tree AOV network Lecture 57: Memory Management I 113 Memory management First fit algorithm Best fit algorithm Lecture 58: Memory Management II 115 Next fit algorithm Lecture 59: Garbage Collection 117 Garbage Collection Marking algorithm Compaction Lecture 60: File Organization 119 Files File Organization vii

9 Data Structures Through C C Revision-I 1 C Revision-I (a) C supports three primary data types - int, char and float. (b) The result of condition1 && condition2 is true, if both the operands are true, otherwise false. (c) The output of condition1 condition2 is false, if both the operands are false, otherwise true. (d) There are three methods by way of which we can repeat a part of a program. They are: Using a for statement Using a while statement Using a do-while statement (e) The do-while tests the condition after having executed the statements within the loop at the least once. [A] Fill In The Blanks: (a) printf( ) and scanf( ) are whereas functions such as add( ) and delete( ) are. (b) The function is conveyed information through. (c) If the function returns no value then its declaration precedes the keyword. [B] What will be the output of the following: (a) main( ) { int a [5] = { 5,1,15,20,25 } ; int i, j, k = 1, m ; i = ++a [1] ; j = a [1]++ ; m = a [ i++] ; printf ( %d, %d, %d, i, j, m ) ; } (b) main( ) { static int count = 5 ; printf ( "\ncount = %d", count-- ) ; if ( count!= 0 ) main( ) ; } [D] Attempt the following: (a) Write a program to calculate the sum of first 10 terms of the series: 1/1! + 2/2! + 3/3! + 4/4!

10 Data Structures Through C C Revision-II 3 C Revision-II (a) Data Structures is the way to organize the data and the operations performed on the data. (b) In a call by value the value of each of the actual arguments in the calling function is copied into corresponding formal arguments of the called function. (c) In a call by reference the addresses of actual arguments in the calling function are copied into formal arguments of the called function. (d) A variable that can hold multiple values is known as an array. (e) The array elements are stored at adjacent memory locations. [A] Fill In The Blanks: (a) static int a [10] ; sets all elements of array to. (b) Array of pointers contain. (c) In the declaration int *arr [100], arr acts as. (d) The format specifier used to access the address of a variable is. [B] What will be the output of the following: (a) main( ) { struct gospel { int num ; char mess1 [50] ; char mess2 [50] ; } m ; m.num = 1 ; strcpy ( m.mess1, "If all that you have is hammer" ) ; strcpy ( m.mess2, "Everything looks like a nail" ) ; /* assume that the strucure is located at address 1004 */ printf ( "\n%u %u %u", &m.num, m.mess1, m.mess2 ) ; } (b) main( ) { int i = 4, j = -1, k = 0, w, x, y, z ; w = i j k ; x = i && j && k ; y = i j && k ; z = i && j k ; printf ( "\nw = %d x = %d y = %d z = %d", w, x, y, z ) ; }

11 4 C Revision-II Data Structures Through C [D] Attempt the following: (a) Implement sieve of Eratosthenes as per the following logic: Step- 1 Fill an array num[100] with numbers from 1 to 100. Step- 2 Starting with the second entry in the array, set all its multiples to step zero. Step- 3 Proceed to the next non-zero element and set all its multiples to zero. Step- 4 Repeat step 3 till you have set up the multiples of all the non-zero elements to zero. Step- 5 At the conclusion of step 4, all the non-zero entries left in the array would be prime numbers, so print out these numbers. (b) Write a program that will print out all the rotations of a string typed into it. For example, the rotations of the word "space" are: space paces acesp cespa espac

12 Data Structures Through C Searching 5 Searching (a) An Array is a finite collection of similar elements stored in adjacent memory locations. (b) The steps to solve a problem is known as an algorithm. (c) In linear search method, the element is sequentially searched in the list. (d) In binary search method, to search an element we compare it with the element present at the center of the list. [A] State True or False: (a) A data structure is said to be linear if its element form a sequence. (b) Binary search always requires the list of elements be in sorted order. (c) In linear search and binary search the list is always sorted. [B] Fill In The Blanks: (a) and are the types of algorithms. (b) While writing an algorithm we enclose the abbreviated description for the step within. (c) Important features of the algorithm are,,,, and. (d) Each algorithm is given a name to identify which is written in.

13 Data Structures Through C Searching and Frequency Count 7 Searching and Frequency Count (a) When sum of cubes of each digit of a number is the number itself it is said to be an Armstrong number. (b) The number of operations performed by an algorithm is directly proportional to the time taken to execute the algorithm. [A] State True or False: (a) While analyzing recursive algorithms we need to determine how many times the loop is executed. (b) If the algorithm s complexity is a combination of a two terms, we can safely ignore the slower growing term as per the rate of increase table. (c) In linear search and binary search the list is always sorted. [B] Fill In The Blanks: (a) Traversing an array means. (b) Accomplishing a task in finite number of steps is called as an. (c) The time complexity for an iterative algorithm is determined by calculating the work done in the. [C] Write algorithms and programs for the following: (a) To reverse a given string. (b) To get the biggest and smallest element in the given array.

14 Data Structures Through C Analysis of Searching Methods 9 Analysis of Searching Methods (a) Based on the order algorithms can be grouped into three categories: Big Omega ( f ) Big Oh O ( f ) Big Theta ( f ) (b) There are two average-cases for a linear search algorithm. The first assumes that the search is always successful and the other assumes that the value being searched will sometimes not be found. (c) The maximum divisions required for binary search is log 2 ( N+1 ). [A] True or False: (a) Big theta represents a class of functions that grow no faster than f. (b) Rate of growth is dominated by largest term in the equation. (c) Hashing is a sorting technique. [B] Fill in the blanks: (a) An algorithm on its order can be categorized as, and. (b) Function to measure the time complexity for an algorithm is of machine architecture. (c) is dominated by largest term in an equation.

15 Data Structures Through C Hashing 11 Hashing (a) Hashing Functions are: Division Mid Square Folding Digit Analysis (b) The formula to evaluate a hash value in Linear probing is ( f ( x ) + i ) % b where: f ( x ) is the hash value of the element obtained before linear probing, i is the counter ranging between one to number of buckets, and b is the total number of buckets. (c) The formula to evaluate a hash value in quadratic probing is ( f ( x ) + i2 ) % b and ( f ( x ) - i2 ) % b where: f ( x ) is the hash value of the element obtained before quadratic probing, i is the counter ranging between one to number of buckets, and b is the total number of buckets. [A] True or False: (a) When two identifiers hash into the same bucket it is called as Collision. (b) Under mid square method for hashing we always calculate the binary equivalent of the number. (c) The number of digits for hash value should always be 4 in Digit analysis method. (d) Each bucket in the hash table can have several slots. [B] Fill in the blanks: (a) Collision Handling Techniques are and. (b) is hashing technique, which performs division. (c) The average case analysis of linear search is. (d) The worst case for binary search is. (e) are used as the hash value in mid square method. [C] Match the Following: (a) Division of Array (1) Compile time memory allocation. (b) Static memory allocation (2) Rehashing. (c) Dynamic Memory allocation (3) Binary search

16 12 Hashing Data Structures Through C (d) Collision handling (e) Complexity measurement [D] Write short notes: (a) Quadratic probing (b) Halving nature of binary search (c) Big Oh notation (d) Cases in analysis (4) Big Oh Notation (5) Run time memory allocation

17 Data Structures Through C Sorting 13 Sorting (a) To arrange the elements of a list in a particular order (ascending or descending) is called as Sorting. (b) The elements compared in bubble sort are always adjacent. (c) Under radix sort the elements are sorted using queues. The number of queues is equivalent to the base of the elements. [A] Fill in the blanks: (a) The elements compared in bubble sort are always. (b) The frequency count for selection sort and bubble sort is. (c) The number of queues in radix sort depends on. [B] What will be the output of the following programs: (a) main( ) { int i ; for ( i = 0 ; i <= ; i++ ) printf ( "\n%d", i ) ; } (b) int i = 0 ; main( ) { printf ( "\nmain s i = %d", i ) ; i++ ; val( ) ; printf ( "\nmain's i = %d", i ) ; val( ) ; } val( ) { i = 100 ; printf ( "\nval's i = %d", i ) ; i++ ; }

18 Data Structures Through C Sorting & Recursion 15 Sorting & Recursion (a) Insertion sort is implemented by inserting a particular element at the appropriate position. (b) Recursion means a function that calls itself. Any function can be called recursively. [A] Fill in the blanks: (a) Recursion means a function that calls. (b) If no condition is preceded with the recursive call then it becomes an. (c) Recursive algorithms are also called as algorithms. (d) To calculate the complexity for a divide and conquer algorithm the complexity for,, and is required to be known. (e) Recursion provides an elegant solution to the program but recursive function. [B] What will be the output of the following programs: (a) main( ) { int x, y, s = 2 ; s *= 3 ; y = f ( s ) ; x = g ( s ) ; printf ( "\n%d %d %d", s, y, x ) ; } int t = 8 ; f ( int a ) { a += -5 ; t -= 4 ; return ( a + t ) ; } g ( int a ) { a = 1 ; t += a ; return ( a + t ) ; } (b) main( ) { int i, j ; for ( i = 1 ; i < 5 ; i++ ) { j = g ( i ) ; printf ( "\n%d", j ) ;

19 16 Sorting & Recursion Data Structures Through C } } g ( int x ) { static int v = 1 ; int b = 3 ; v += x ; return ( v + x + b ) ; } [C] Attempt the following: (a) A positive integer is entered through the keyboard, write a program to obtain the prime factors of the number. Modify the function suitably to obtain the prime factors recursively. (b) Write a recursive function to obtain the first 20 numbers of a Fibonacci sequence. In a Fibonacci sequence the sum of two successive terms gives the third term. Following are the first few terms of the Fibonacci sequence:

20 Data Structures Through C Quick Sort 17 Quick Sort (a) Quick sort works on the splitting mechanism or the divide and conquer mechanism. (b) Quick sort is also known as partition exchange sort. (c) One of the elements is considered as the pivot element and the sort aims at bringing this pivot to a position such that one array has elements less than the pivot and the other array has elements greater than the pivot. (d) The pivot element is not necessarily the first element in the list. (e) The best case for quick sort is when the list is divided each time in approximately two equal halves. (f) Worst case time complexity for quick sort is O ( n 2 ) that is similar to bubble and insertion sort. (g) The best case time complexity is O ( log 2 n ). (h) Quick sort is better to insertion and bubble sort in average case. [A] State True or False: (a) The pivot element in quick sort is always the middle element in the list. (b) Each pass in quick sort yields the pivot element to its final position in the list. (c) In quick sort the list is rearranged in every pass such that all elements smaller than the pivot are moved before it and all elements larger than the pivot are moved after it. (d) The number of comparisons made in worst case for quick sort is similar to radix sort and insertion sort. (e) Swapping the elements in average case reduces 2n 2 inversions in comparison to bubble sort and insertion sort. (f) Time complexity of quick sort in average case is n 2 and worst case is n log n. (g) All sorting work in quick sort is done on the way back up in the recursive process. (h) Quick sort is also known as partition exchange sort. [B] Fill In The Blanks: (a) In the function quicksort( ), a condition is checked whether is greater than. If the condition is satisfied then only the array will be into two parts, otherwise, the control will simply be returned. (b) The loop is executed within the split( ) function that checks whether the indexes p and q. (c) When the control returns to the function quicksort( ) are made to function quicksort( ). (d) The efficiency of the quick sort method can be improved by,, and.

21 18 Quick Sort Data Structures Through C [C] Attempt the following: (a) If original list for quick sort is 6, 2, 4, 7, 1, 3, 8, 5 give the output produced by hand execution. (b) If original list for quick sort is 15, 4, 10, 8, 6, 9, 16, 1, 7, 3, 11, 14, 2, 5, 12, 13 give the output produced by hand execution.

22 Data Structures Through C Structures-I 19 Structures-I (a) Instead of taking different arrays for different types of data, all the data items can be grouped together into one data type called structure. (b) A structure is a collection of dissimilar elements. (c) A structure is declared using struct keyword. (d) Following the keyword struct, is the name of the structure or tag. Within the braces structure members / elements are declared. (e) The structure elements are stored in contiguous memory locations. [A] Point out the errors, if any: (a) Look at the declarations below and point out the errors. struct time { int hours ; int minutes ; int seconds ; } t ; struct time *tt ; tt = &t ; printf( %d, tt.seconds); (b) Look at the code snippet below and point out the errors. main( ) { struct student { char name[20] ; int age; } ; struct student s1 = { Rahul, 10} ; struct student s2, s3 ; s2.name = s1.name ; s2.age = s1.age ; s3 = s1 ; printf ( %s %d,s3.n,s3.a); } [B] State True or False: (a) All structure elements are stored in contiguous memory locations. (b) An array should be used to store dissimilar elements, and a structure to store similar elements. (c) In an array of structures, not only are all structures stored in contiguous memory locations, but also the elements of individual structures are also stored in contiguous locations.

23 20 Structures-I Data Structures Through C (d) Nested structures are not allowed. [C] Fill In The Blanks: (a) The structure elements can be accessed by using the and operators. (b) If the base address of an array of structures is passed to a function, it would be collected in a. (c) If a structure pointer is to be used to access the structure elements, the operator needs to be used. (d) In the declaration of a structure the keyword is followed by the of the structure.

24 Data Structures Through C Structures-II 21 Structures-II (a) On incrementing a structure pointer, it is incremented by the sizeof the struct. (b) All the members of one structure can be copied into another by simple assignment. (c) A structure can be nested within another structure. (d) If a structure is passed by reference, then the structure elements can be accessed by using the -> (arrow) operator. [A] Attempt the following: (a) Create a structure named india with structure elements as cityname, population, tot_literate. Now create a variable city that contains 50 elements of type india. Populate it with values and display only those citynames where literacy is 80% or more. (b) Write a menu driven program which displays following menu: sort by Salary sort by Designation After selecting 1 st option, list should be displayed accordingly. After selecting 2 nd option list should be displayed but a subtotal of salary should also be displayed after each designation change. Fields to be displayed are name, designation, basic, hra, conveyance, salary. [Designations could be exec, mgr, sec, etc.]. (c) Create a structure called employee with data members as name, date_of_joining and salary. Write a program that accepts a date and displays a list of those employees whose tenure is 3 or more than 3 years from accepted date.

25 Data Structures Through C 2D Arrays 23 2D Arrays (a) If a lot of elements from a matrix have a value 0 then the matrix is known as a sparse matrix. (b) A common way of representing non-zero elements of a sparse matrix is the 3-tuple forms. [A] State True or False: (a) If a lot of elements from a matrix have a value other than 0 then the matrix is known as a sparse matrix. (b) There is a precise definition of when a matrix is sparse and when it is not.

26 Data Structures Through C Sparse Matrices 25 Sparse Matrices (a) In 3-tuple form each non-zero element is stored in a row, with the 1 st and 2 nd element of this row containing the row and column in which the element is present in the original matrix. (b) The 3 rd element in this row stores the actual value of the non-zero element. [A] Pick up the correct alternative for each of the following questions: (a) A matrix is called sparse when (1) Most of its elements are non-zero. (2) Most of its elements are zero. (3) All of its elements are non-zero. (4) None of the above. (b) A sparse matrix can be lower-triangular matrix (1) When all the non-zero elements lie only on the leading diagonal. (2) When all the non-zero elements lie above leading diagonal. (3) When all the non-zero elements lie below leading diagonal. (4) Both (2) and (3). [B] State True or False: (a) A sparse matrix can be represented using a linked list. (b) When addition or multiplication of sparse matrices is performed, it is not possible to predict the size of the resultant matrix. (c) Tridiagonal matrix is the one in which the non-zero elements are placed below or above the leading diagonal.

27 Data Structures Through C Transpose Of Sparse Matrices 27 Transpose of Sparse Matrices (a) There are two ways in which information of a 3-tuple can be stored: Arrays Linked List (b) In both representations information about the non-zero elements is stored. [A] Fill In The Blanks: (a) matrix is the one in which the non-zero elements are placed below or above the leading diagonal. (b) A common way of representing non-zero elements of a sparse matrix is the forms. (c) The number of columns in the 3-tuple form would always be. (d) In the 3-tuple form, the 0 th column stores the number, the 1 st column stores the number and the 2 nd column stores the value of. [B] Attempt the following: (a) Write a program to obtain the transpose of a matrix.

28 Data Structures Through C Addition Of Sparse Matrices 29 Addition of Sparse Matrices (a) As the number of non-zero elements in a sparse matrix may vary, it would be efficient to use a linked list to represent it. (b) A sparse matrix, which is also a square matrix, can fall in the following categories: Diagonal: Where the non-zero elements are stored on the leading diagonal of the matrix. Tridiagonal: Where the non-zero elements are placed below or above the leading diagonal. Lower Triangular: Where the non-zero elements are placed below the leading diagonal. Upper Triangular: Where the non-zero elements are placed above the leading diagonal. [A] Attempt the following: (a) Write a program to subtract two sparse matrices implemented as an array. (b) Write a program to multiply two sparse matrices implemented as an array.

29 Data Structures Through C Multiplication Of Sparse Matrices 31 Multiplication of Sparse Matrices (a) The prerequisite for matrix multiplication is that row number for one of the matrix is similar to column number for another matrix. (b) Since the array elements are stored in adjacent memory locations any element of the array can be accessed, once the base address of the array and number of rows and columns present in the array is known. [A] State True or False: (a) C language permits Row Major arrangement as well as the Column Major arrangement. (b) Once the base address of the array and number of rows and columns present in the array is known, we can access the array elements easily. (c) For an array a[m][n] as per Row Major arrangement the address of element a[i][j] would be Base address + j * m + i. [B] Fill In The Blanks: (a) The syntax used to declare a 2D array includes two subscripts, of which one specifies the number of and the other specifies the number of of the array. (b) Arr[3][4] is an array containing rows and columns. (c) When a 2D array is stored in the memory, the array elements are stored in memory locations. (d) The two possible arrangements of elements in the memory are arrangement and the arrangement.

30 Data Structures Through C Storage 33 Storage (a) When a 2D array gets stored in memory, all its elements are stored linearly. (b) There are two possible arrangements of elements in memory Row Major arrangement and Column Major arrangement. (c) In general for an array a[m][n] as per Row Major arrangement the address of element a[i][j] would be Base address + i * n + j. (d) For an array a[m][n] as per Column Major arrangement the address of element a[i][j] would be Base address + j * m + i. (e) C language permits only a Row Major arrangement. [A] Attempt the following: (a) Build an array called chess to represent a chessboard. Use 0 for black and 1 for white boxes. (b) A square matrix is called symmetric if for all values of i and j, a[i][j] = a[j][i]. Write a program, which verifies whether a given 3 x 3 matrix is symmetric, or not. (c) Find the location of the element a[1][2][2][1] from a 4D integer array a[4][3][4][3] if the base address of the array is 1002.

31 Data Structures Through C Dynamic Memory Allocation 35 Dynamic Memory Allocation (a) The size of the array remains fixed or static. (b) We can dynamically allocate memory through the malloc( ) function. (c) If there are lots of global variables used in a program, then the loader may fail in loading them. (d) If too many local variables are present in our program then it may cause stack overflow. [A] State True or False: (a) The size of an array can be changed dynamically. (b) Linked list is used to store similar data. (c) All nodes in the linked list must always be in non-contiguous memory locations. (d) It is necessary that the link part of the last node in a linked list must contain NULL.

32 Data Structures Through C Linked Lists 37 Linked Lists (a) In a linked list, each element points to the next element. (b) Each element of the linked list is called a node. (c) Each node consists of two parts viz., the data and the link to the next node. (d) A linked list can hold integers, floats, strings or even multiple data types. [A] Attempt the following: (a) Write a program to add a new node at the end of the linked list. (b) Write a program to find number of nodes in a linked list. (c) Write a program to erase all the nodes of a linked list. (d) Write a program to copy one linked list into another.

33 Data Structures Through C Operations on Linked Lists-I 39 Operations on Linked Lists I (a) Linked list is a very common data structure often used to store similar data in memory. (b) Linked list is a collection of elements called nodes, each of which stores two items of information an element of the list and a link. (c) The elements of a linked list are not constrained to be stored in adjacent locations. (d) A linked list can grow and shrink in size during its lifetime. [A] State True or False: (a) There is no maximum size of a linked list. (b) The individual elements of a linked list are dispersed in memory. [B] Attempt the following: (a) Write a program to list the current directory in alphabetical order using a linked list. Hints: Use standard library functions findfirst( ) and findnext( ) in Turbo C to read the directory entries. Define a structure struct node, which contains the standard structure struct ffblk defined in file "dos.h" as data part, and add another element next as link to the next node. When all the directory entries are read and stored in the linked list, sort the linked list and then display the sorted linked list.

34 Data Structures Through C Operations on Linked Lists-II 41 Operations on Linked Lists-II (a) As nodes (elements) of a linked list are stored at different memory locations it hardly happens that we fall short of memory when required. (b) Unlike arrays, while inserting or deleting the nodes of the linked list, shifting of nodes is not required. (c) The order of the elements of linked list is maintained by explicit links between them. (d) Various types of operations can be performed on a linked list. For example, adding new nodes at the beginning, at the end or in the middle of the linked list, displaying and counting the nodes of the linked list, deleting a node form the linked list, deleting all the nodes in the linked list, sorting the elements in the list etc. [A] State True or False: (a) The elements of a linked list must be in a sorted order. (b) Sorting of the elements of the linked list can be performed by keeping the data in the nodes intact and just by readjusting the links between the nodes. [B] Attempt the following: (a) Write a program that reads the name, age and salary of 10 persons and maintains them in a linked list sorted by name. (b) There are two linked lists A and B containing the following data: A: 3, 7, 10, 15, 16, 9, 22, 17, 32. B: 16, 2, 9, 13, 37, 8, 10, 1, 28. Write a program to create: A linked list C that contains only those elements that are common in linked list A and B. A linked list D that contains all elements of A as well as B ensuring that there is no repetition of elements.

35 Data Structures Through C Operations on Linked Lists-III 43 Operations on Linked Lists III (a) All elements of a linked list can be accessed by first setting up a pointer pointing to the first node in the list and then traversing the entire list using this pointer. (b) Concatenation of two linked lists means appending one list at the end of the other. [A] State True or False: (a) In a linked list, if we lose the location of the first node then it is as good as having lost the entire linked list. (b) Polynomials cannot be stored using a linked list. [B] Attempt the following: (a) There are two linked lists A and B containing the following data: A: 7, 5, 3, 1, 20 B: 6, 25, 32, 11, 9 Write a function to combine the two lists such that the resulting list contains nodes in the following elements: 7, 6, 5, 25, 3, 32, 1, 11, 20, 9 You are not allowed to create any additional node while writing the function.

36 Data Structures Through C Operations on Linked Lists-IV 45 Operations on Linked Lists IV (a) Some of the operations that are carried out on linked lists can be easily implemented using recursion. (b) Polynomials can also be represented using linked lists. (c) It is possible to carry out various polynomial operations like polynomial addition etc using the linked lists. [A] Attempt the following: (a) Create two linked lists to represent the following polynomials: 9 x x x x x x + 9 Write a function add( ) to add these polynomials and print the resulting linked list.

37 Data Structures Through C Circular Linked Lists 47 Circular Linked Lists (a) In a circular linked list, if we begin at a given node and traverse the entire list, we ultimately end up at the starting point. (b) A circular linked list can be used to represent a stack and a queue. (c) A circular linked list has no knowledge about where the previous node lies in memory. [A] State True or False: (a) If a pointer p points to a node in a linked list, we cannot reach any of the nodes that precede the node to which p is pointing. (b) If a pointer p is pointing to one of the nodes in a circular linked list, then moving the pointer to the next node would cause a memory leak.

38 Data Structures Through C Doubly Linked Lists 49 Doubly Linked Lists (a) In a doubly linked list, along with the address of next node, the address of the previous node in the linked list is also stored in each node of the linked list. (b) In a doubly linked list, we can traverse the list in the forward as well as in the backward direction from a given intermediate node in the list. (c) While adding a new node to a doubly linked list, both the links to the previous node as well as the next node have to be set. [A] State True or False: (a) Doubly linked list facilitates movement from one node to another in either direction. (b) A doubly linked list will occupy less space as compared to a corresponding singly linked list. (c) If we were to traverse from last node to first node it would be easier to do so if the linked list is singly linked instead of doubly linked. (d) In a structure used to represent the node of a doubly linked list it is necessary that the structure elements are in the order backward link, data, forward link. [B] Attempt the following: (a) Write a program to add a new node to a doubly linked list. (b) Write a program to count the nodes present in a doubly linked list. (c) Write a program to delete an existing node from a doubly linked list. (d) Write a program to add a node at the beginning of a doubly linked list. (e) Write a program to add a node at a specified position in a doubly linked list.

39 Data Structures Through C Sparse Matrices as Linked List-Is 51 Sparse Matrices as Linked Lists I (a) When we carry out addition or multiplication of sparse matrix using the 3-tuple array representation, it is not possible to predict beforehand how many elements in the resultant matrix would be non-zero. (b) Instead of an array, we can represent the sparse matrix in the form of a linked list. (c) In the linked list representation a separate list is maintained for each column as well as each row of the matrix. (d) A node in a list stores the information about the non-zero element of the sparse matrix. (e) The head node for a column list stores the column number, a pointer to the node, which comes first in the column, and a pointer to the next column head node. [A] Pick up the correct alternative for the following: (a) In the linked representation of a sparse matrix the head node for a column list stores (1) A pointer to the next column head node. (2) A pointer to the first node in column list. (3) Column number. (4) All of the above. [B] Fill In The Blanks: (a) If a particular column list is empty then the field down of the column head node would be. (b) If a row list is empty then the field of the row head node would be empty. (c) A node in a list stores the information about the element of the sparse matrix. (d) The information stored in this special node is used for.

40 Data Structures Through C Sparse Matrices as Linked Lists-II 53 Sparse Matrices as Linked Lists-II (a) Similarly, a head node for a row list stores, a pointer to the node, which comes first in the row list, and a pointer to the next row head node. (b) A node stores the row number, column number and the value of the non-zero element of the sparse matrix. (c) The node also stores a pointer to the node that is immediately to the right of it in the row list as well as a pointer to the node that is immediately below it in the column list. (d) In addition to this a special node is used to store the total number of rows, total number of columns, a pointer to the first row head node and a pointer to the first column head node. (e) The information stored in this special node is used for traversing the list. [A] Attempt the following: (a) Write a program to build a sparse matrix as a linked list. (b) Write a program that provides functions for following operations on a sparse matrix represented as a linked list: (i) Store an element when the row number, column number and the value are provided. (ii) Retrieve an element for given row and column number of the matrix.

41 Data Structures Through C Linked List Using Recursion 55 Linked List Using Recursion (a) In C, it is possible for the functions to call themselves. (b) A function is called 'recursive' if a statement within the body of a function calls the same function. (c) Recursion is also called 'circular definition'. (d) Recursion is the process of defining something in terms of itself. [A] Fill In The Blanks: (a) A function is called if a statement within the body of a function calls the same function. (b) is also called 'circular definition'. [B] Attempt the following: (a) Using recursion write a program to find number of nodes in a linked list that represents a polynomial.

42 Data Structures Through C Linked List Using Unions 57 Linked List Using Unions (a) Unions are derived data types, the way structures are. (b) Both structures and unions are used to group a number of different variables together. (c) A union offers a way for a section of memory to be treated as a variable of one type on one occasion, and as a different variable of a different type on another occasion. (d) The union elements are accessed exactly the same way in which the structure elements are accessed, using a. operator. (e) When a two-byte number is stored in memory, the low byte is stored before the high byte. [A] What will be the output of the following programs: (a) main( ) { } (b) main( ) { } union { int i[2] ; long l ; } u ; u.i[0] = 0x50 ; u.i[1] = 0x45 ; printf ( "\n%lu", u.l ) ; union a { int i1 ; int i2 ; char s[4] ; } ; union a m ; strcpy ( a.s, "AAA" ) ; printf ( "\n%s", a.s ) ; printf ( "\n%u %u", a.i1, a.i2 ) ; [B] State True or False: (a) We can t assign different values to the different union elements at the same time. (b) When a two-byte number is stored in memory, the high byte is stored before the low byte.

43 58 Linked List Using Unions Data Structures Through C (c) A union variable occupies as much data as what a corresponding structure variable would occupy, elements of both remaining same. (d) Union provides us a way to look at the same memory locations in more than one way, which a structure cannot. (e) It is possible to have nested unions. (f) A union in a structure, or a structure in a union is not allowed. [C] Fill In The Blanks: (a) The union elements are accessed using a operator. (b) We can access the elements of the union in a structure using the operator twice.

44 Data Structures Through C Generalized Linked List 59 Generalized Linked List (a) We can t assign different values to the different union elements at the same time. (b) Just as one structure can be nested within another, a union too can be nested in another union. (c) There can be a union in a structure, or a structure in a union. (d) The depth of the empty generalized list is defined to be zero. [A] Fill In The Blanks: (a) When a two-byte number is stored in memory, the byte is stored before the byte. [B] Attempt the following: (a) Using recursion write a program to copy one polynomial represented as a linked list into another. (b) Using recursion write a program to add a new node at the end of the linked list.

45 Data Structures Through C Stacks 61 Stacks (a) A Stack is a data structure in which addition of new element or deletion of an existing element always takes place at the same end. [A] Fill in the blanks: (a) A stack is a data structure in which addition of new element or deletion of an existing element always takes place at an end called. (b) The data structure stack is also called structure.

46 Data Structures Through C Stacks As Linked List 63 Stacks As Linked List (a) The arithmetic expressions can be written in three forms: Infix Postfix Prefix (b) While writing an arithmetic expression, the operator symbol is usually placed between two operands. This is called as infix notation. [A] Pick up the correct alternative for each of the following questions: (a) Adding an element to the stack means (1) Placing an element at the front end. (2) Placing an element at the top. (3) Placing an element at the rear end. (4) None of the above. (b) Pushing an element to a stack means (1) Removing an element from the stack. (2) Searching a given element in the stack. (3) Adding a new element to the stack. (4) Sorting the elements in the stack. (c) Popping an element from the stack means (1) Removing an element from the stack. (2) Searching a given element in the stack. (3) Adding a new element to the stack. (4) Sorting the elements in the stack.

47 Data Structures Through C Stack Expressions 65 Stack Expressions (a) While evaluating an infix expression usually the following operator precedence is used: Highest priority: Exponentiation ( $ ) Next highest priority: Multiplication ( * ) and Division ( / ) Lowest priority: Addition ( + ) and Subtraction ( - ) [A] Fill in the blanks: (a) In notation the operators precedes the two operands. (b) In notation the operator follows the two operands. [B] Transform the following infix expressions into their equivalent postfix expressions: (a) ( A - B ) * ( D / E ) (b) ( A + B ^ D ) / ( E - F ) + G

48 Data Structures Through C Stack Operations 67 Stack Operations (a) In prefix notation the operator comes before the operands. (b) In postfix notation, the operator follows the operands. [A] Write programs for the following: (a) Copying contents of one stack to another.

49 Data Structures Through C Postfix 69 Postfix (a) While evaluating postfix expression, the expression is scanned from left to right. [A] True or False: (a) Stack is of fixed size. (b) The expressions within a pair of parentheses are always evaluated earlier than other operations. (c) Every character of the infix expression to be converted to postfix expression is scanned from right to left. (d) If character scanned is an operand, then it is directly added to the target expression.

50 Data Structures Through C Infix To Prefix 71 Infix To Prefix (a) While evaluating prefix expression, the expression is scanned from right to left. [A] Fill in the blanks: (a) A stack is generally implemented with two basic operations:. (b) The place where stacks are frequently used is. (c) The used in an arithmetic expression represent the operations like addition, subtraction, multiplication, division and exponentiation. (d) While evaluating an infix expression, the highest priority operator is. (e) In postfix to prefix conversion, the expression in postfix form is scanned from.

51 Data Structures Through C Postfix To Prefix 73 Postfix To Prefix (a) In the conversion from postfix to prefix, while concatenating the operator with the two elements popped from the stack, the concatenation should be of the form operator s2 s1 where s1 is the first popped element and s2 is the 2 nd popped element. [A] Transform the following infix expressions into their equivalent prefix expressions: (a) ( A - B ) * ( D / E ) (b) A * ( B + D ) / E - F * ( G + H / K )

52 Data Structures Through C Postfix To Infix 75 Postfix To Infix (a) In the conversion from postfix to infix, while concatenating the operator with the two elements popped from the stack, the concatenation should be of the form s2 operator s1 where s1 is the first popped element and s2 is the 2 nd popped element. [A] Transform each of the following postfix expression to infix: (a) A B - C + D E F - + $ (b) A B C D E - + $ * G F * -

53 Data Structures Through C More Conversions 77 More Conversions (a) The expression in prefix form to be converted to postfix form is scanned from left to right. (b) The expression in prefix to be converted to infix form is scanned from right to left. [A] True or False: (a) In prefix to infix conversion, we scan the expression from right to left.

54 Data Structures Through C Queue-I 79 Queue I (a) Queue is a linear data structure that permits insertion of new element at one end and deletion of an element at the other end. (b) The first element that gets added into the queue is the first one to get removed from the list. [A] True or False: (a) Queue is a non-linear data structure. (b) The first element that gets added into the queue is the last one to get removed from the list. (c) Queue permits insertion of new element at one end and deletion of an element at the other end. [B] Choose the correct alternative for the following: (a) Queue is a (1) Linear data structure. (2) Non-linear data structure. (3) Both (1) and (2). (4) None of the above. (b) The end at which a new element gets added to a queue is called (1) Front. (2) Rear. (3) Top. (4) Bottom. (c) The end from which an element gets removed from the queue is called (1) Front. (2) Rear. (3) Top. (4) Bottom. (d) Queue is also called (1) Last-In-First-Out data structure. (2) First-In-Last-Out data structure. (3) First-In-First-Out data structure. (4) Last-In-Last-Out data structure. [C] Write programs for the following: (a) Write a program to add elements to a queue implemented as a circular linked list. (b) Write a program to delete elements from a queue implemented as a circular linked list.

55 Data Structures Through C Queue-II 81 Queue II (a) In the implementation of queue there is a possibility that the queue is reported as full, even though in actuality there might be empty slots at the beginning of the queue. (b) A priority queue is a collection of elements where the elements are stored according to their priority levels. (c) The order in which the elements should get added or removed is decided by the priority of the element. [A] True or False: (a) Deque is a generalization of both a stack and a queue. (b) Queue can be represented only as linked lists. [B] Fill in the blanks: (a) The word is a short form of double-ended queue. (b) A is a collection of elements where the elements are stored according to their priority levels.

56 Data Structures Through C Deque & Priority Queue 83 Deque & Priority Queue (a) The circular queue would be reported as full only when all the slots in the array stand occupied. (b) The word deque is a short form of double-ended queue. (c) Deque is a data structure in which items can be added or deleted at either the front or rear end, but no changes can be made elsewhere in the list. [A] True or False: (a) The circular queue would be reported as full as soon as we reach the end of the array. (b) If there are elements with the same priority, then the element added first in the queue would get processed. [B] Fill in the blanks: (a) The would be reported as full only when all the slots in the array stand occupied. (b) The element with a priority is processed before any element of priority. [C] Write programs for the following: (a) Write a program to copy one queue to another when the queue is implemented as a linked list. (b) Write a program to implement priority queue as an array.

57 Data Structures Through C Trees 85 Trees (a) Trees and graphs are non-linear data structures. (b) In a tree structure, each node may point to several other nodes, which in turn may point to several other nodes. (c) Forest is a set of several trees that are not linked to each other in any way. [A] State True or False: (a) A binary tree whose non-leaf nodes have left and right child is a complete binary tree. (b) The number of nodes attached to a particular node in a tree is called the degree of the node. (c) Trees and graphs are non-linear data structures. [B] Fill in the blanks: (a) is a set of several trees that are not linked to each other in any way. (b) The children of a node are called as.

58 Data Structures Through C Tree Traversal 87 Tree Traversal (a) The number of nodes connected to a particular node is called the degree of a particular node. (b) A complete binary tree of depth d is a strictly binary tree in which all the leaves of the tree are at the same level d. (c) The methods of binary tree traversal are in-order traversal, pre-order traversal and post-order traversal. [A] State True or False: (a) While traversing a non-empty binary tree in pre-order traversal, we first visit the root, then the right sub tree and lastly the left sub tree. (b) If every non-leaf node in a binary tree has non-empty left and right sub-trees, the tree is termed a strictly binary tree. [B] Fill in the blanks: (a) The methods of binary tree traversal are traversal, traversal and traversal. (b) The root of the tree has level. (c) The of a binary tree is the maximum level of any leaf in the tree. [C] Answer the Following: (a) Give the pre-order, post-order and in-order traversal steps of the following tree. (b) Write a program to represent a binary tree using an array.

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

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

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

Table of Contents. Chapter 1: Introduction to Data Structures... 1

Table of Contents. Chapter 1: Introduction to Data Structures... 1 Table of Contents Chapter 1: Introduction to Data Structures... 1 1.1 Data Types in C++... 2 Integer Types... 2 Character Types... 3 Floating-point Types... 3 Variables Names... 4 1.2 Arrays... 4 Extraction

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

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned. Course Name: B.Tech. 3 th Sem. Subject: Data Structures No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours Paper Code: ETCS-209 Topic Details No of Hours Planned

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

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

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

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

End-Term Examination Second Semester [MCA] MAY-JUNE 2006 (Please write your Roll No. immediately) Roll No. Paper Code: MCA-102 End-Term Examination Second Semester [MCA] MAY-JUNE 2006 Subject: Data Structure Time: 3 Hours Maximum Marks: 60 Note: Question 1.

More information

Data Structures Through C. Student Handout Book

Data Structures Through C. Student Handout Book Data Structures Through C Student Handout Book Contents Lecture : C Revision I Importance of data structures Data types in C Instructions and its types The decision control instruction Working of logical

More information

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8) B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER 2009 EC 2202 DATA STRUCTURES AND OBJECT ORIENTED Time: Three hours PROGRAMMING IN C++ Answer ALL questions Maximum: 100 Marks 1. When do we declare a

More information

ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n))

ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n)) ASSIGNMENTS Chapter Q. No. Questions Course Outcom e (CO) Progra m Outcom e I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n)) 2 3. What is the time complexity of the algorithm? 4

More information

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \ BSc IT C Programming (2013-2017) Unit I Q1. What do you understand by type conversion? (2013) Q2. Why we need different data types? (2013) Q3 What is the output of the following (2013) main() Printf( %d,

More information

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC) SET - 1 II B. Tech I Semester Supplementary Examinations, May/June - 2016 PART A 1. a) Write a procedure for the Tower of Hanoi problem? b) What you mean by enqueue and dequeue operations in a queue? c)

More information

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May www.jwjobs.net R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 *******-****** 1. a) Which of the given options provides the

More information

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I TWO MARKS UNIT I- 2 MARKS

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I TWO MARKS UNIT I- 2 MARKS DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I TWO MARKS UNIT I- 2 MARKS 1. Define global declaration? The variables that are used in more

More information

Data Structures Question Bank Multiple Choice

Data Structures Question Bank Multiple Choice Section 1. Fundamentals: Complexity, Algorthm Analysis 1. An algorithm solves A single problem or function Multiple problems or functions Has a single programming language implementation 2. A solution

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

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

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION COURSE TITLE DATA STRUCTURE DETAILED SYLLABUS SR.NO NAME OF CHAPTERS & DETAILS HOURS ALLOTTED 1 USER DEFINED DATATYPE /STRUCTURE About structure Defining structure Accessing structure element Array of

More information

1. Attempt any three of the following: 15

1. Attempt any three of the following: 15 (Time: 2½ hours) Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Make suitable assumptions wherever necessary and state the assumptions made. (3) Answers to the same question must be written

More information

Question Bank Subject: Advanced Data Structures Class: SE Computer

Question Bank Subject: Advanced Data Structures Class: SE Computer Question Bank Subject: Advanced Data Structures Class: SE Computer Question1: Write a non recursive pseudo code for post order traversal of binary tree Answer: Pseudo Code: 1. Push root into Stack_One.

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

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3 UNIT 3 LINEAR DATA STRUCTURES 1. Define Data Structures Data Structures is defined as the way of organizing all data items that consider not only the elements stored but also stores the relationship between

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

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu. 17CA 104DATA STRUCTURES Academic Year : 018-019 Programme : MCA Year / Semester : I / I Question Bank Course Coordinator: Mrs. C.Mallika Course Objectives The student should be able to 1. To understand

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

DATA STRUCTURES AND ALGORITHMS

DATA STRUCTURES AND ALGORITHMS DATA STRUCTURES AND ALGORITHMS UNIT 1 - LINEAR DATASTRUCTURES 1. Write down the definition of data structures? A data structure is a mathematical or logical way of organizing data in the memory that consider

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

Reg. No. : Question Paper Code : 27157

Reg. No. : Question Paper Code : 27157 WK 3 Reg. No. : Question Paper Code : 27157 B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER 2015. Time : Three hours Second Semester Computer Science and Engineering CS 6202 PROGRAMMING AND DATA STRUCTURES

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

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

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May Code No: R21051 R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 DATA STRUCTURES (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 Answer any FIVE Questions All Questions carry

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

DS ata Structures Aptitude

DS ata Structures Aptitude DS ata Structures Aptitude 1. What is data structure? 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

Types of Data Structures

Types of Data Structures DATA STRUCTURES material prepared by: MUKESH BOHRA Follow me on FB : http://www.facebook.com/mukesh.sirji4u The logical or mathematical model of data is called a data structure. In other words, a data

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

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

Algorithms and programs, basic idea of pseudo-code.algorithm efficiency and analysis, time and space analysis of algorithms order notations.

Algorithms and programs, basic idea of pseudo-code.algorithm efficiency and analysis, time and space analysis of algorithms order notations. B. P. Poddar Institute of Management & Technology Department of Information Technology Course Syllabus : Data Structure & Algorithm Academic Year:.18-19... Semester:...3rd... Module -I. [8L] Linear Data

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

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

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

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures MIDTERM EXAMINATION Spring 2010 CS301- Data Structures Question No: 1 Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the

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

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

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

Code No: R Set No. 1

Code No: R Set No. 1 Code No: R05010106 Set No. 1 1. (a) Draw a Flowchart for the following The average score for 3 tests has to be greater than 80 for a candidate to qualify for the interview. Representing the conditional

More information

Visit ::: Original Website For Placement Papers. ::: Data Structure

Visit  ::: Original Website For Placement Papers. ::: Data Structure Data Structure 1. What is data structure? 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 about the relationship

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

GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING (07) / INFORMATION TECHNOLOGY (16) / INFORMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES

GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING (07) / INFORMATION TECHNOLOGY (16) / INFORMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING () / INFMATION TECHNOLOGY (6) / INFMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES Type of course: Compulsory SUBJECT CODE: 2302 B.E. 3 rd Semester

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

( ) ( ) 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

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass Marks: 24

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass Marks: 24 Prepared By ASCOL CSIT 2070 Batch Institute of Science and Technology 2065 Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass

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

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

) $ f ( n) " %( g( n)

) $ f ( n)  %( g( n) CSE 0 Name Test Spring 008 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to compute the sum of the n elements of an integer array is: # A.

More information

Computer Science E-22 Practice Final Exam

Computer Science E-22 Practice Final Exam name Computer Science E-22 This exam consists of three parts. Part I has 10 multiple-choice questions that you must complete. Part II consists of 4 multi-part problems, of which you must complete 3, and

More information

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1 CSE 0 Name Test Fall 00 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each t. What is the value of k? k=0 A. k B. t C. t+ D. t+ +. Suppose that you have

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

Lecture 26. Introduction to Trees. Trees

Lecture 26. Introduction to Trees. Trees Lecture 26 Introduction to Trees Trees Trees are the name given to a versatile group of data structures. They can be used to implement a number of abstract interfaces including the List, but those applications

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

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT) D B3D042 Pages: 2 Reg. No. Name: APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 Max. Marks: 100 CS205: DATA STRUCTURES (CS, IT) PART A Answer all questions.

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

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

PESIT Bangalore South Campus Department of MCA Course Information for

PESIT Bangalore South Campus Department of MCA Course Information for 1. GENERAL INFORMATION: PESIT Bangalore South Campus Department of MCA Course Information for Data Structures Using C(13MCA21) Academic Year: 2015 Semester: II Title Code Duration (hrs) Lectures 48 Hrs

More information

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

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

More information

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

Cpt S 122 Data Structures. Course Review Midterm Exam # 1 Cpt S 122 Data Structures Course Review Midterm Exam # 1 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 1 When: Friday (09/28) 12:10-1pm Where:

More information

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D. CSE 0 Name Test Fall 00 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to convert an array, with priorities stored at subscripts through n,

More information

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer) COSC 2007 Data Structures II Final Exam Thursday, April 13 th, 2006 This is a closed book and closed notes exam. There are total 3 parts. Please answer the questions in the provided space and use back

More information

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο CSE 220 Name Test Fall 20 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 4 points each. The time to compute the sum of the n elements of an integer array is in:

More information

Bioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang)

Bioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang) Bioinformatics Programming EE, NCKU Tien-Hao Chang (Darby Chang) 1 Tree 2 A Tree Structure A tree structure means that the data are organized so that items of information are related by branches 3 Definition

More information

PROGRAMMING IN C AND C++:

PROGRAMMING IN C AND C++: PROGRAMMING IN C AND C++: Week 1 1. Introductions 2. Using Dos commands, make a directory: C:\users\YearOfJoining\Sectionx\USERNAME\CS101 3. Getting started with Visual C++. 4. Write a program to print

More information

8. Write an example for expression tree. [A/M 10] (A+B)*((C-D)/(E^F))

8. Write an example for expression tree. [A/M 10] (A+B)*((C-D)/(E^F)) DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES UNIT IV NONLINEAR DATA STRUCTURES Part A 1. Define Tree [N/D 08]

More information

Question And Answer.

Question And Answer. Q.1 What is the number of swaps required to sort n elements using selection sort, in the worst case? A. &#920(n) B. &#920(n log n) C. &#920(n2) D. &#920(n2 log n) ANSWER : Option A &#920(n) Note that we

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

NET/JRF-COMPUTER SCIENCE & APPLICATIONS. Time: 01 : 00 Hour Date : M.M. : 50

NET/JRF-COMPUTER SCIENCE & APPLICATIONS. Time: 01 : 00 Hour Date : M.M. : 50 1 NET/JRF-COMPUTER SCIENCE & APPLICATIONS UNIT TEST : DATA STRUCTURE Time: 01 : 00 Hour Date : 02-06-2017 M.M. : 50 INSTRUCTION: Attempt all the 25 questions. Each question carry TWO marks. 1. Consider

More information

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

( ) + n. ( ) = n 1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1 CSE 0 Name Test Summer 00 Last Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose you are sorting millions of keys that consist of three decimal

More information

3 The L oop Control Structure

3 The L oop Control Structure 3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement

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

Lecture Notes. char myarray [ ] = {0, 0, 0, 0, 0 } ; The memory diagram associated with the array can be drawn like this

Lecture Notes. char myarray [ ] = {0, 0, 0, 0, 0 } ; The memory diagram associated with the array can be drawn like this Lecture Notes Array Review An array in C++ is a contiguous block of memory. Since a char is 1 byte, then an array of 5 chars is 5 bytes. For example, if you execute the following C++ code you will allocate

More information

Adapted By Manik Hosen

Adapted By Manik Hosen Adapted By Manik Hosen Question: What is Data Structure? Ans: The logical or mathematical model of particular organization of data is called Data Structure. Question: What are the difference between linear

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

CP2 Revision. theme: dynamic datatypes & data structures

CP2 Revision. theme: dynamic datatypes & data structures CP2 Revision theme: dynamic datatypes & data structures structs can hold any combination of datatypes handled as single entity struct { }; ;

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF INFORMATION TECHNOLOGY QUESTION BANK III SEMESTER CS8391-Data Structures Regulation 2017 Academic Year 2018 19(odd Semester)

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 in C++ Using the Standard Template Library

Data Structures in C++ Using the Standard Template Library Data Structures in C++ Using the Standard Template Library Timothy Budd Oregon State University ^ ADDISON-WESLEY An imprint of Addison Wesley Longman, Inc. Reading, Massachusetts Harlow, England Menlo

More information

S.E. Sem. III [INFT] Data Structures & Analysis. Primitive Linear Non Linear

S.E. Sem. III [INFT] Data Structures & Analysis. Primitive Linear Non Linear S.E. Sem. III [INFT] Data Structures & Analysis Time : 3 Hrs.] Prelim Paper Solution [Marks : 80 Q.1(a) Explain different types of data structures with examples. [5] Ans.: Types of Data Structure : Data

More information

Cpt S 122 Data Structures. Data Structures

Cpt S 122 Data Structures. Data Structures Cpt S 122 Data Structures Data Structures Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Introduction Self Referential Structures Dynamic Memory Allocation

More information

DATA STRUCTURE. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

DATA STRUCTURE. Exclusive for IACE Students   iacehyd.blogspot.in Ph: /422 Page 1 DATA STRUCTURE Data Structure: Data structure is the structural representation of logical relationships between elements of data. In other words a data structure is a way of organizing data items by considering

More information

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο CSE 0 Name Test Fall 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally

More information

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

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis p. 5 Statement Constructs p. 5 Pseudocode Example p.

More information

About this exam review

About this exam review Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review

More information

( ) n 3. n 2 ( ) D. Ο

( ) n 3. n 2 ( ) D. Ο CSE 0 Name Test Summer 0 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) B. Θ( max( m,n, p) ) C.

More information

Course Review for Finals. Cpt S 223 Fall 2008

Course Review for Finals. Cpt S 223 Fall 2008 Course Review for Finals Cpt S 223 Fall 2008 1 Course Overview Introduction to advanced data structures Algorithmic asymptotic analysis Programming data structures Program design based on performance i.e.,

More information

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers? Review for Final (Chapter 6 13, 15) 6. Template functions & classes 1) What is the primary purpose of template functions? A. To allow a single function to be used with varying types of arguments B. To

More information

COMP 250 Fall recurrences 2 Oct. 13, 2017

COMP 250 Fall recurrences 2 Oct. 13, 2017 COMP 250 Fall 2017 15 - recurrences 2 Oct. 13, 2017 Here we examine the recurrences for mergesort and quicksort. Mergesort Recall the mergesort algorithm: we divide the list of things to be sorted into

More information

UCS-406 (Data Structure) Lab Assignment-1 (2 weeks)

UCS-406 (Data Structure) Lab Assignment-1 (2 weeks) UCS-40 (Data Structure) Lab Assignment- (2 weeks) Implement the following programs in C/C++/Python/Java using functions a) Insertion Sort b) Bubble Sort c) Selection Sort d) Linear Search e) Binary Search

More information

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

( ). Which of ( ) ( )  #& ( )  # g( n) ( )  # f ( n) Test 1 CSE 0 Name Test Summer 006 Last Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply two n x n matrices is: A. "( n) B. "( nlogn) # C.

More information