Vous êtes sur la page 1sur 4

Q.

55 The size of array int a[5]={1,2} is (A) 4 (B) 12 (C) 10 (D) 6 Ans: C The size of int array is 2*5=10 bytes as int takes 2 bytes of storage. Q.41 Which is not dynamic memory allocation function? (A) malloc (B) free (C) alloc (D) calloc Ans: C Three dynamic memory allocation functions are: malloc, calloc and free. Q.68 The postfix form of the following infix notation is : ( A + B) * ( C*D E) * F (A) AB + CD*E *F* (B) AB+ CDE + * F* (C) AB+ CD EF + ** (D) ABCDEF* + * + Ans: (A)

Q.94 A complete Binary Tree with 15 nodes contains________edges (A) 15 (B) 30 (C) 14 (D) 16 Ans: (C) Q.109 Applications of Linked List are (A) Simulation , event driven systems (B) Postfix and prefix manipulations (C) Dictionary systems, polynomial manipulations (D) Fixed block storage allocation, garbage collection Ans: (D) Q.120 Which of the following operations is performed more efficiently by doubly linked list than by singly linked list (A) Deleting a node whose location is given. (B) Searching of an unsorted list for a given item. (C) Inserting a new node after node whose location is given. (D) Traversing the list to process each node. Ans: (A) Q.128 A complete binary tree with n leaf nodes has (A) n+1 nodes (B) 2n-1 nodes (C) 2n+1 nodes (D) n(n-1)/2 nodes Ans: (B)

Q.132 Overflow condition in linked list may occur when attempting to_____ (A) Create a node when free space pool is empty. (B) Traverse the nodes when free space pool is empty. (C) Create a node when linked list is empty. (D) None of these. Ans: (A) Q.136 The postfix form of A ^ B * C - D + E/ F/ (G + H), (A) AB^C*D-EF/GH+/+ (B) AB^CD-EP/GH+/+* (C) ABCDEFGH+//+-*^ (D) AB^D +EFGH +//*+ Ans: (A) Q.139 A full binary tree with 'n' non-leaf nodes contains (A) log2 n nodes . (B) n+1 nodes. (C) 2n nodes. (D) 2n+l nodes. Ans: (D) Q.52 What is a linked list? List different types of linked list. Write a C program to demonstrate a simple linear linked list. (2+2+6) Ans: Linked list: A linked list is a self referential structure which contain a member field that point to the same structure type. In simple term, a linked list is collections of nodes that consists of two fields, one containing the information about that node, item and second contain the address of next node. Such a structure is represented as follows:
struct node { int item; struct node *next; };

Info part can be any of the data type; address part should always be the structure type. Linked lists are of following types: 1. Linear Singly linked list: A list type in which each node points to the next node and the last node points to NULL. 2. Circular linked list: Lists which have no beginning and no end. The last node points back to the first item.

3. Doubly linked list or Two-way linked list: These lists contain double set of pointers, one pointing to the next item and other pointing to the preceding item. So one can traverse the list in either direction. 4. Circularly doubly linked list: It employs both the forward and backward pointer in circular form. A program to demonstrate simple linear linked list is given below:
#include<stdio.h> #include<stdlib.h> #define NULL 0 struct linked_list { int number; struct linked_list *next; }; typedef struct linked_list node; void main() { node *head; void create(node *p); int count(node *p); void print(node *p); clrscr(); head=(node *)malloc(sizeof(node)); create(head); printf("\n"); print(head); printf("\n"); printf("\n Number of items = %d \n",count(head)); getch(); } void create(node *list) { printf("Input a number\n"); printf("(type -999 to end) : "); scanf("%d",&list->number); if(list->number == -999) list->next=NULL; else { list->next=(node *)malloc(sizeof(node)); create(list->next); } return; } void print(node *list) { if(list->next!=NULL) { printf("%d - ->",list->number); if(list->next->next == NULL) printf("%d",list->next->number); print(list->next); } return; } int count(node *list)

{ if(list->next == NULL) return(0); else return(1+count(list->next));

Vous aimerez peut-être aussi