![]() |
![]() |
![]() |
![]() |
|||||
|
Data Structures, Algorithms and Programming Questions and Answers
Contents 1 Data Structures, Algorithms and Programming 1.1. What is a data structure? 1.2. List out the areas in which data structures are applied extensively? 1.3. What are the major data structures used in the following areas: RDBMS, Network data model and Hierarchical data model? 1.4. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? 1.5. Minimum number of queues needed to implement the priority queue? 1.6. What is the data structures used to perform recursion? 1.7. What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms? 1.8. Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations. 1.9. Sorting is not possible by using which of the following methods? Insertion, Selection, Exchange, Deletion 1.10. A binary tree with 20 nodes has -- null branches? 1.11. What are the methods available in storing sequential files? 1.12. How many different trees are possible with 10 nodes? 1.13. List out few of the Application of tree data-structure? 1.14. List out few of the applications that make use of Multilinked Structures? 1.15. In tree construction which is the suitable efficient data structure? Array, Linked list, Stack, Queue, none 1.16. What is the type of the algorithm used in solving the 8 Queens problem? 1.17. In an AVL tree, at what condition the balancing is to be done? 1.18. What is the bucket size, when the overlapping and collision occur at same time? 1.19. Traverse the given tree using Inorder, Preorder and Postorder traversals. 1.20. There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a full binary tree? 1.21. In the given binary tree, using array you can store the node 4 at which location? 1.22. Sort the given values using Quick Sort? 1.23. For the given graph, draw the DFS and BFS? 1.24. Classify the Hashing Functions based on the various methods by which the key value is found. 1.25. What are the types of Collision Resolution Techniques and the methods used in each of the type? 1.26. In RDBMS, what is the efficient data structure used in the internal storage representation? 1.27. Draw the B-tree of order 3 created by inserting the following data arriving in sequence – 92 24 6 7 11 8 22 4 5 16 19 20 78 1.28. Of the following tree structure, which is, efficient considering space and time complexities? Incomplete Binary Tree, Complete Binary Tree, Full Binary Tree 1.29. What is a spanning Tree? 1.30. Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes? 1.31. Convert the given graph with weighted edges to minimal spanning tree. 1.32. Which is the simplest file structure? Sequential, Indexed, Random 1.33. Whether Linked List is linear or Non-linear data structure? 1.34. Draw a binary Tree for the expression: A * B - (C + D) * (P / Q) 1.35. What is the major advantage of a Hash table? 1.36. What are some of the applications of a Hash table? 1.37. What are the techniques that you use to handle the collisions in hash tables? How do you implement overflow in Hash? 1.38. In one of the implementation of chained hash tables, the actual hash code used for accessing the table is the hash code modulo the table size. Why is this? 1.39. Why are hash tables good for random access but not sequential access? For example, in a database system in which records are to be accessed in a sequential fashion, what is the problem with hashing? 1.40. What is the worst-case performance of searching for an element in a chained hash table? How do we ensure that this case will not occur? 1.41. What is the worst-case performance of searching for an element in an open-addressed hash table? How do we ensure that this case will not occur? 1.42. Compare hashing with binary tree. 1.43. Describe how would you forward or include requests between servlets and JSPs. 1.44. How could you determine if a linked list contains a cycle in it, and, at what node the cycle starts? 1.45. How would you reverse a doubly-linked list? 1.46. Assume you have an array that contains a number of strings (perhaps char * a[100]). Each string is a word from the dictionary. Your task, described in high-level terms, is to devise a way to determine and display all of the anagrams within the array (two words are anagrams if they contain the same characters; for example, tales and slate are anagrams.) 1.47. Given the following prototype: int compact(int * p, int size); write a function that will take a sorted array, possibly with duplicates, and compact the array, returning the new length of the array. That is, if p points to an array containing: 1, 3, 7, 7, 8, 9, 9, 9, 10, when the function returns, the contents of p should be: 1, 3, 7, 8, 9, 10, with a length of 5 returned. 1.48. Write a function memset(s, c, n) that sets n bytes of memory to the byte c, starting at address s, and returns s. 1.49. Write a function that returns the maximum value in an array of numbers. 1.50. Write a function to raise x to the power of n. 1.51. Reverse an array in Java 1.52. Write a function to find length of a string but without using the pointer arithmetic. 1.53. Write a function to find length of a string using the pointer arithmetic. 1.54. Write a function int_to_str() that takes a string as parameter, returns integer value. 1.55. Write a function str_to_int() that takes a int as parameter, and returns the string equivalent. 1.56. Convert a Number to a String 1.57. You are presented with a linked list, which may have a “loop” in it. That is, an element of the linked list may incorrectly point to a previously encountered element, which can cause an infinite loop when traversing the list. Devise an algorithm to detect whether a loop exists in a linked list. How does your answer change if you cannot change the structure of the list elements? 1.58. Given a Process A that collects user inputs through a GUI and passes input parameters to Process B on another machine which in turn records the data to a data base. As a system designer, what considerations would you take into account? What technologies would you employ? 1.59. Write a function to reverse a linked list p? 1.60. Write a function that returns the factorial of a number. 1.61. Write an implementation of strlen(). 1.62. Write an implementation of strcmp(char *s1, char *s2)). 1.63. Write an implementation of strstr(char *s1, char *s2)). 1.64. What should a professional software designer consider in the design and implementation of code? 1.65. Write C’s standard tolower() library function that converts characters to lowercase. 1.66. Reverse a string in place - word by word: initial: the house is blue 1.67. Where is the problem? for(unsigned int i=100;i>=0;i--) { dosomething(); } 1.68. Write a Java program to check if a string is a palindrome. 1.69. Write a function to convert from lowercase to uppercase. 1.70. Converting a Hexadecimal String to int 1.71. Reading a String from the Standard Input. 1.72. Passing Arrays by Value 1.73. Write a function to swap two pointers (Using Pointers to Pointers). 1.74. Write a generic function that takes variable datatype parameters. 1.75. A Power function for Integers 1.76. Convert a decimal to a Binary by repeated division 1.77. Binary File Copying 1.78. How can you detect your machine’s Endian? 1.79. When are pointers equal? 1.80. Why you should avoid direct access to data members 1.81. A general base class - is it such a good idea? 1.82. How to generate a sequence of random numbers? 1.83. How to access an Object from another process? 1.84. Designing Applications for Symmetric Multiprocessing Environments 1.85. Writing binary data to an ofstream 1.86. Inserting Elements into Arrays 1.87. When does a virtual member function impose runtime overhead? 1.88. Return type of an overriding virtual member function 1.89. A Pure Virtual Destructor 1.90. Why default arguments in Virtual Functions must be identical? 1.91. When to use a pure Virtual member function? 1.92. Checking whether a Stack is empty 1.93. How to access the topmost element of a Stack? 1.94. When can an empty class be useful? 1.95. Why functions should not return a reference to a local object? 1.96. Returning Objects by Value 1.97. Garbage Collector in C++? 1.98. What are the differences between an Argument and a Parameter? 1.99. Recursion in the real world 1.100. Remove an element in a sorted array 1.101. Use Register variables to enhance performance 1.102. Reading a String from a File 1.103. Prefix versus Postfix Operators 1.104. Write an equation for leap year. 1.105. Write an infinite loop. 1.106. Write an implementation of strlen() 1.107. Separate a string into tokens? 1.108. Write an efficient function to find the first non-repeated character in a string. For instance, the first non-repeated character in “total” is ‘o’ and the first non-repeated character in “teeter” is ‘r’. Discuss the efficiency of the algorithm. 1.109. Write a function to remove duplicate integers in a sorted ascending integer array. 1.110. Write a function that determines whether a computer is big-endian or little-endian. 1.111. Write a function that determines the number of 1 bits in the computer’s internal representation of a given integer. 1.112. Given the following prototype: int compact(int * p, int size); Write a function that will take a sorted array, possibly with duplicates, and compact the array, returning the new length of the array. That is, if p points to an array containing: 1, 3, 7, 7, 8, 9, 9, 9, 10, when the function returns, the contents of p should be: 1, 3, 7, 8, 9, 10, with a length of 5 returned. Using Big O notation describe the computational complexity of your solution. 1.113. Given the following prototype: int FindOneOf(const char *a, const char *b); Write a function which accepts 2 strings and determines which character in string b appears first in string a. Using Big O notation describe the computational complexity of your solution. 1.114. Write a function which reverses the order of the doubly linked list pointed to by head and returns the new head element. For example if the list pointed to by head upon entry looks like this: 1.115. Write a function to capitalize, that is, change first letter to uppercase. 1.116. Write a function to capitalizeWords 1.117. Write a function to center 1.118. Write a function to count number of characters 1.119. Write a function to deleteChar 1.120. Write a function to isAlpha 1.121. Write a function to isPalindrome 1.122. Write a function to myStrcat 1.123. Write a function to myStrcmp 1.124. Write a function to myStrcpy 1.125. Write a function to myStrlen 1.126. Write a function to padLeft 1.127. Write a function to padRight. 1.128. Write a function to reverse the characters in a string. 1.129. Write a function to trimLeft. 1.130. Write a function to remove trailing blanks from a string. 1.131. Write a function to truncate an array or string to length if it’s longer. 1.132. Write a function to move characters. 1.133. Write a function to print numbers with commas separating the thousands. 2 Other Books by Author 2.1. Project Management Questions and Answers 2.2. Management and Leadership Questions and Answers 2.3. Software Development Questions and Answers 2.4. Java Questions and Answers 2.5. C and C++ Questions and Answers 2.6. Database and Data Warehouse Questions and Answers 2.7. Web Development Questions and Answers 2.8. UNIX Questions and Answers 2.9. Networks Questions and Answers
|
||||