Skip to main content

Posts

Showing posts from October, 2011

Data Structure & Algorithm Interview Questions And Answers - Part X.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 46) What do you mean by Polish string ? Answer:  Polish string refers to the notation in which the operator symbol is placed either before its operands (prefix notation) or after it operands (postfix notation). The usual form, in which the operator is placed in between the operands is called infix notation. 47) What do you mean by an infix, postfix and prefix expression ? Answer: An expression where operators are placed in between the operands is called a  infix expression . E.g.: A + B An expression where operators are placed after the operands is called a postfix expression . E.g.: AB+ An expression where operators are placed before the operands is called a prefix expression . E.g.: +AB 48) What is the evaluation order according to which an infix expression is converted to postfix expression ? Answer: The evaluat

Data Structure & Algorithm Interview Questions And Answers - Part IX.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 41) What do you mean by bubble sort ? Bubble sort is an array sorting technique in which the adjoining values are compared and exchanged if they are not in the proper order. The process repeats until the entire array is sorted. 42) What is insertion sort ? In insertion sort , each successive element is picked from its position and inserted at an appropriate position in the previously sorted array. 43) Differentiate between the different types of linked lists ? Linked lists are of two types viz, singly linked or one-way lists and doubly linked or two-way lists . Singly linked lists contain node with single pointer pointing to the next node in sequence whereas doubly linked lists contain two pointers , one pointing to previous node and other pointing to the next node in sequence. 44) What do you mean by ‘pushing’ and ‘pop

Data Structure & Algorithm Interview Questions And Answers - Part VIII.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 36) What are the differences between linear search and binary search ? The differences between linear and binary searches are: Binary search carries out the searching process with the minimum number of comparisons but linear search does not guarantee lesser number of comparisons. To save on time and comparisons, binary search is much more beneficial than linear search. Binary search can work for only sorted arrays whereas linear search can work for both sorted as well as unsorted arrays. 37) State the condition(s) under which binary search is applicable ? The conditions for binary search are: The list must be sorted. Lower bound and upper bound, and the sort order of the list must be known. 38) What are the advantages of linked lists over arrays ? Linked lists overcome the drawbacks of arrays as in linked

Data Structure & Algorithm Interview Questions And Answers - Part VII.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 31) List the basic operations which can be performed on data structures ? The basic operations which can be performed on data structures are: Insertion : Addition of new element into a data structure. Deletion : Removal of a data element from a data structure. Searching : Searching for and finding a specified data element in a data structure. Traversal : Traversing along a data structure and processing all the data elements of it. Sorting : Arranging data elements of a data structure in a specified order. Merging : Combining elements of two similar data structures to form a new data structure of same type. 32) How can you calculate the size of an array, given the upper and lower bounds of the array ? When upper bound and lower bound of an array are given, its size is calculated as: Array size (length) = UB – LB + 1

Data Structure & Algorithm Interview Questions And Answers - Part VI.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 26) What are the different types of arrays? Arrays are of different types namely one-dimensional arrays, two-dimensional arrays and multi-dimensional arrays. One-dimensional arrays comprise of finite homogeneous elements while multi-dimensional arrays comprise of elements, each of which is itself an array. 27) What do you mean by the base address of an array? In memory, one-dimensional arrays are implemented by allocating a sequence of addressed locations so as to accommodate all its elements. The starting address of the very first element of the array is called base address of the array. 28) Give the formula to calculate the address of any element in an array, when the length of the array along with its base address and size of the element are given ? The formula to calculate address of any element in an array is: Add

Data Structure & Algorithm Interview Questions And Answers - Part V.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 21) What advantages and disadvantages, do you think does a circular singly linked list have over a non-circular singly linked list? A circular singly linked list is advantageous over a non-circular singly linked list because the former helps in sequencing from any node to any other node in the list. And the disadvantage is that it can make the end of the list more difficult to detect than if the last node contained a NULL next pointer. 22) Give the similarities between queues and stacks ? Both queues and stacks are special cases of linear lists . Both can be implemented as arrays or linked lists . 23) Differentiate between queues and stacks ? The differences between queues and stacks are: A stack is a LIFO list while a queue is a FIFO list . There are no variations of stack. A queue, however, may be circular or de

Data Structure & Algorithm Interview Questions And Answers - Part IV.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 16) What Is A Circular Queue ? Circular queues are the queues implemented in circular form rather than a straight line. In these types of queue, the last element is always followed by the first element. 17) What Do You Mean By The Terms ‘Overflow’ & ‘Underflow’ In Data Structures ? Overflow and Underflow are two states in data structures when further insertions and deletions respectively are not possible in the data structure. Overflow refers to inserting a node when no memory is available and Underflow refers to deleting from an empty list. 18) What Is Meant By Dequeue ? Queues in which elements can be added or removed at either end but not in the middle are called dequeues. There are two types of dequeue namely input restricted dequeue and output restricted dequeue. 19) What Do You Mean By Garbage Collection

Data Structure & Algorithm Interview Questions And Answers - Part III.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 11) What Is A Stack ? Stack data structure refers to the lists stored and accessed in a special way, where LIFO or Last in First Out technique is followed. In stacks, insertions and deletions take place only at one end, called the top. Stack is similar to a stack of plates or a stack of CDs arranged vertically. In either stacks, objects, i.e. plates or CDs are inserted or removed only from the top of the stack. 12) What Is A Queue ? Queue data structure is a FIFO or First in First Out list, where insertions take place at the rear end of the queue and deletions take place at the front end of the queue. Queue is much the same as a line of people waiting for their turn to vote, or a queue at a railway station. The first person will be the first in the queue and a new person can join the queue at the rear end of it. 13) Wha

Data Structure & Algorithm Interview Questions And Answers - Part II.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 6) What Are Non Linear Data Structures ? Non linear data structures are multi level data structures. Examples of non linear data structure are trees and graphs . In such non linear data structures, the elements share a hierarchical relationship among themselves rather than forming a sequence. 7) Differentiate Between Data Types & Data Structures ? A data type is a named group of data with similar characteristics and behavior, E.g.: Integer, real, Boolean, character etc. A data structure is a named group of data of different data types , organized in a particular format and characterized by specific operations that can be performed on it. E.g.: Queues, arrays, trees etc. 8) List Four Major Operations On Linear Data Structures ? Four major operations performed on linear data structures are: • Searching : Refer

Data Structure & Algorithm Interview Questions And Answers - Part I.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview. 1) What Is Data Structure? A named group of data, of different data types, which can be processed as a single unit is referred to as a data structure. Data structures have well-defined operations, behavior and properties. Arrays, stacks, queues, trees are all examples of data structures. 2) What Is The Need For Data Structures In Programming? There are various situations in real life when there is need to treat a group of different data types as a single unit. For example, a record in a file has several fields of different data types and the entire record may be required to be processed in one unit. In such a case, data structures are essential to combine different data types and process them together. 3) What Are The Different Data Types Which A Data Structure May Comprise Of? Data structures contain mainly three dif

Sample C Program To Convert String To An Integer Using atoi() Function.

#include <stdio.h> #include <conio.h> #include <stdlib.h> int main() { int i; i = atoi (" 100"); printf(" The integer value is: %d ", i); getch(); return 0; } OUTPUT: The integer value is: 100 NOTE: If you liked the post/article or if you think this post/article helped you in any way, then please show your appreciation by filling up at least one form from the options given below:

Sample C Program To Sort A Given Number Of Strings.

C Program To Sort A Given Number Of Strings. #include <stdio.h> #include <conio.h> #include <string.h> main() { char str[4][10]; int i; clrscr(); for( i = 0; i < 4; i++ )   {      printf(“ \n Enter name %d: ”, i+1 );      scanf(“ %s ”, str[i] );   } printf(“\n Original Order \n”); for(i = 0; i < 4; i++ )      printf(“ %s\t ”, str[i] ); for(i = 0; i < 4; i++ )   {     for(j = i + 1; j < 4; j++ )        if( strcmp(str[i], str[j]) > 0 )          {             strcpy( temp, str[i] );             strcpy( temp, str[i], str[j] );             strcpy( str[j], temp );          }   } printf(“\n Sorted Order \n”); for( i = 0; i < 4; i++ )     printf(“ %s\t ”, str[i]); getch(); } OUTPUT: Enter name 1: John Enter name 2: Mac Enter name 3: William Enter name 4: Allen Original Order John Mac William Allen Sorted Order Allen John Mac William ALSO READ: -- Program to accept a string and print it b

Sample C Program To Swap Two Strings Using strcpy() Function.

#include <stdio.h> #include <conio.h> #include <string.h> main() { Char s1[10], S2[10], temp[10]; clrscr(); printf(“ Enter first name \n ”); scanf(“ %s ”, s1); printf(“ Enter second name \n ”); scanf(“ %s ”, s2); printf(“ Before swapping \n ”); printf(“ s1 = %s\ts2 = %s\n ”, s1, s2); strcpy(temp, s1); strcpy(s1, s2); strcpy(s2, temp); printf(“ After swapping \n ”); printf(“ s1 = %s\ts2 = %s\n ”, s1,s2); getch(); } OUTPUT: Enter first name Lavanya Enter second name Suchita Before swapping s1 = Lavanya s2 = Suchita After swapping s1 = Suchita s2 = Lavanya ALSO READ: -- Program to accept a string and print it by using the while loop. -- Program to accept a string in upper case and print it in lower case. -- Program to accept a string in any case and print it by another case. -- Program to accept a string and print each word in new line. -- Program to accept a string and count no of capital letters, no. of small letters and

Sample C Program To Multiply Two Matrix.

C Program To Multiply Two 3 * 3 Matrix : #include <stdio.h> #include <conio.h> #include <stdlib.h> main() { int a[3][3], b[3][3], c[3][3]; int i, j, k; clrscr(); printf(" Enter elements of first matrix \n "); for( i = 0; i < 3; i++ )   {     for( j = 0; j < 3; j++ )       {          printf(" \n Enter a[%d] [%d] element: ", i, j);

Sample C Program To Transpose A Matrix .

C Program To Find Transpose a 3 * 2 matrix. #include <stdio.h> #include <conio.h> #include <stdlib.h> main() { int arr[3] [2]; int i, j; clrscr(); printf(" Enter the 6 elements of matrix\ n "); for( i = 0; i < 3; i++ )    for( j = 0; j < 2; j++ )        scanf(" %d ", &arr[i] [j]);   printf(" The matrix is \n "); for( i = 0; i < 3; i++ )   {