Pick a Course

## Frequently asked Questions For Gate Computer Science Interview

In order to get admission in MTech in top institutes of india or selection in PSU's ,or get selection in top MNC's one has to go under the process of interview. In interview generally one's preference is asked, in which subjects he/she is comfortable. Experts at Gate-Prepladder have compiled some questions and answers which might be useful to you.

### Question : what is hashing?

Hashing is mapping of large amount of data item into smaller table with the help of hashing function. It is technique to convert a range of key values into a range of indexes of an array. Due to this hashing process, the result is a Hash data structure that can store or retrieve data items in a constant speed with respect to size of collection.

Hash Table or HashMap is a data structure which uses hash function to generate key corresponding to the associated value.

Let us consider the following rollno’s numbers and produce a hashcode:

1) 12038811385 => 1+2+0+3+8+8+1+1+3+8+5=40
Hence, (40)%12

Hashcode=4

2) 31018131277=> 3+1+0+1+8+1+3+1+2+7+7=34
Hence, (34)%12

Hashcode=10

3) 04117643855 => 0+4+1+1+7+6+4+3+8+5+5=44
Hence, (44)%12

Hashcode=8

Hence large number can be stored in small indexes. These hash codes becomes the indexes. But with large data there comes problem of collision that is 2 or 3 rollno’s having same hashcode. Many algorithms are designed to remove collision like linear probing, open addressing.

### Question : How many stacks are required to implement a queue?

We need 2 stacks to implement a queue. Since we know stack is LIFO and queue is FIFO. Take one stack we insert 1,2 ,3,4 in first stack. If we consider queue output, it should be 1,2,3,4 and stack output is 4,3,2,1 . Now  insert 4,3,2,1 (deque from first stack) in second stack. When we deque from stack 2 ,we will get output of queue.

### Question : Explain the differences between structured data and unstructured data?

Structured data is information, usually text files which can easily be processed by data mining tools.

Unstructured data are:

• Emails
• Word Processing Files
• PDF files
• Digital Images
• Video
• Audio
• Social Media Posts

### Question : What is thrashing?

Thrashing is a condition when a process is busy in swapping pages in and out. It occur when

Size of locality of page > total memory size

This leads to low CPU utilization.

### Question : What is Throughput, Turnaround time, waiting time and Response time?

Turn around Time : The interval from the time of submission of a process to the time of completion i.e (process complete time  - process create time).

Throughput : Number  of processes completed per unit time.

Waiting Time : The sum of the periods spent waiting in the ready queue.

Response Time : The time from the submission of a request until the first response is produced. Response Time is the amount of time it takes to start responding but not the time that it takes the output that response.

### Question : Can I use  int data type to store the value 32768 in  C? Why?

No, its range is from  -32768 to 32767. In order to use it we have use long keyword with int.

### Question : What is wrong with this statement in C? myName  = Rakesh ?

For strings , we cannot use statements like this. We need to use strcpy for above.

### Question : What is the difference between heap and stack ?

Stack is used for static memory allocation and Heap for dynamic memory allocation, both stored in the computer's RAM . Variables allocated on the stack are stored directly to the memory and access to this memory is very fast, and it's allocation is dealt with when the program is compiled

### Question : How to reverse linked list using recursion?

{

Node* first;

Node* rest;

return;

first = *headRef;       // example first = {3, 4,5 }

rest = first->next;  // rest = {5, 4}

if (rest == NULL)

return;

recursiveReverse(&rest);

first->next->next = first;

first->next = NULL;

}

Best Wishes !!