GeekInterview.com
Series: Subject: Topic:

Data Structures Interview Questions

Showing Questions 1 - 20 of 233 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

What is the size of char pointer (in bytes)

Asked By: yashwant patel | Asked On: Dec 5th, 2006

Answered by: shivam shrivastava on: Apr 22nd, 2013

In c++, if the pointer object characterized like a type of char ,int or float in array. So the pointer address contains the 2 bytes address.

Answered by: Nidhi on: Feb 19th, 2007

Actually a pointer is just a address holder so its size is always that of an int data type,what ever may be the type of pointer.In a 16-bit compiler,its 2 bytes and in 32-bit compiler,its 4 bytes(ie depeds on sizeof(int))

The hashstring() member function is called by other member functions of the hashtable class whenever a function needs to convert a ________________.

Asked By: Interview Candidate | Asked On: Dec 10th, 2005

Skill/topic: hash tablea) a hash number key to a keyb) key to a hash number keyc) a key to an indexexplanation: the hashstring() member function is another function called by other member functions of the hashtable class whenever a function needs to convert a key to a hash number key. The hashstring()...

Answered by: rasheed on: Feb 14th, 2013

C) a key to an Index

Answered by: Sandhya.Kishan on: May 21st, 2012

The hashString() member function is called by other member functions of the Hashtable class whenever a function needs to convert a key to hash number key.

The number of swappings needed to short the numbers 8, 22, 7, 9, 31, 19, 5, 13 in ascending order using bubble sort is 1. 11 2. 12 3. 13 4. 14

Asked By: Rujul | Asked On: Mar 9th, 2007

Answered by: Nitish Kamal on: Jan 27th, 2013

14 is answer

Answered by: Ranjan Kumar Ojha on: Mar 13th, 2007

ans will be 14. you can check. #include<iostream> using namespace std; int main() {     int a[]={ 8, 22, 7, 9, 31, 19, 5, 13 };int counter=0;     for(int i=0;i<...

What is the size of a void pointer ?

Asked By: anupam verma | Asked On: Dec 4th, 2006

Answered by: jignesh on: Dec 29th, 2012

Size of void pointer or size of character pointer are same because both variable contain address or we can say memory location

Answered by: ilushka on: Jul 29th, 2011

all pointers are the same size, they only differ on the platform and the amount memory you are trying to address. for example, on an 8051 platform it's 3 bytes, on an intel it's 32 or 64 bits wide.

Getinstance()...

Asked By: Divya6171 | Asked On: Aug 20th, 2012

Please, can anybody answer me that when to use getinstance() and which class having getinstance(),i could not find that method in class class also.

Answered by: RITENDRA on: Nov 1st, 2012

getInstance() method is written inside a class to access the instance of the class from other class. Basically, this is used to ensure that only one instance of the particular class has been created....

The front of the stack in a stack-linked list ______________.

Asked By: Interview Candidate | Asked On: Dec 10th, 2005

Skill/topic: stacks using linked lista) back of the linked listb) front of the linked listc) middle of the linked listd) none of the above

Answered by: pankaj on: Oct 23rd, 2012

Top of stack

Answered by: raj on: Sep 21st, 2012

B) Front of the linked list i.e top

Can a linked list store data other than integers?

Asked By: Interview Candidate | Asked On: Dec 10th, 2005

Skill/topic: stacks and queues: insert, delete, peek, finda) yesb) noexplanation: integers are usually used, but you can modify the data type of the data in the definition of the node to change the kind of data stored in the linked list.

Answered by: real on: Oct 18th, 2012

When we are using structure variable then i will say yes!

Code
  1. struct node{
  2. int info;
  3. string name;
  4. float average;
  5. node *node;
  6. };

Answered by: Rahul Goyal on: Jul 20th, 2012

link list is a data structure not a property of integers...
so, the data the it store can be anything like a class object or structure object etc.

Write a program to insert a node at a given position in a single linked list?

Asked By: Rajasekhar | Asked On: Sep 25th, 2011

Answered by: rjshkr on: Sep 28th, 2012

"c NODE insert(NODE head,int data,int pos) { NODE temp,new,prev = NULL; int i=1; new = (NODE)malloc(sizeof(struct node)); new->info = data; if(head == NULL) { new->link = ...

Answered by: Rahul goyal on: Jul 20th, 2012

Code
  1. //let the structure name be stud
  2. void insert_pos(stud *head, pos)
  3. {
  4.   stud s,*t;
  5.  s.input(); //accept the data
  6.  t=head;
  7. pos--;
  8. while(t!=NULL && pos)
  9. {
  10.   t=t->next;
  11.    pos--;
  12. }
  13. s->next=t->next;
  14. t->next=s;
  15. }
  16.  

What happens if an invalid index value is passed to a function?

Asked By: Interview Candidate | Asked On: Dec 10th, 2005

Skill/topic: stacks and queues: insert, delete, peek, finda) if an invalid index is passed, the function terminates without further processing. [explanation] functions that use an index value always determine if the index passed to them is valid before using the index value . If an invalid index is...

Answered by: Sandhya.Kishan on: Jul 25th, 2012

If the user passes in an invalid index, the program will cause an assertion error. While this is useful to indicate to the user that something went wrong, so they can deal with it as appropriate.

Iterative algorithm

Asked By: zoya | Asked On: Oct 22nd, 2011

Design an iterative algorithm to traverse a binary tree represented in two dimensional matrix

Answered by: Sandhya.Kishan on: Jul 16th, 2012

A binary tree can be traversed using only one dimensional array. InOrder_TreeTraversal() { prev = null; current = root; next = null; while( current != null ) { if(prev == current.parent) { prev = cu...

Why resultset being an interface can call next()

Asked By: j_priyaa | Asked On: Nov 15th, 2007

Answered by: Sandhya.Kishan on: Jul 16th, 2012

A class which implements an interface implements its methods.When we obtain a reference to a ResultSet then we are getting an instance of a class that implements the ResultSet interface.Hence class provides concrete implementations of all of the ResultSet methods.

Read heterogenous linklist

Asked By: unconquerable | Asked On: Nov 3rd, 2010

While creating a heterogenous linklist we know that we use void pointer. But when we need to read the information, how will you do it? How will you figure out to what datatype does the data belong to?

Answered by: Sereche on: Jul 8th, 2012

Some kind of information regarding the type is obviously required. If there is no way of determining it from the context (i.e., the previous node in the list somehow specifies the type), it must be st...

Marbles and floors

Asked By: hari_nowayout | Asked On: Mar 26th, 2011

You have a 100-story building and a couple of marbles. You must identify thelowest floor for which a marble will break if you drop it from this floor. How fastcan you find this floor if you are given an infinite supply of marbles? What if youhave only two marbles?

Answered by: Sereche on: Jul 8th, 2012

Sounds like a simple binary search to me. For 100 floors, you would need at most 7 marbles to reach an answer. More generally, with n floors, you would need ceiling(Log2(n+1)) marbles. If the floors ...

Fuzzy logic system rely on

Asked By: Rujul | Asked On: Mar 25th, 2007

1. Crisp binary choices 2. Ambiguous data 3. Decision makers 4. All of them

Answered by: Sandhya.Kishan on: Jun 13th, 2012

Fuzzy logic system relays on all Crisp binary data, ambiguous data and on decision makers.

Why are data members of the hashtable class stored in the priVATe access specifier?

Asked By: Interview Candidate | Asked On: Dec 10th, 2005

Skill/topic: hash tablea) data members of the hashtable class are stored in the priVATe access specifier to ensure the integrity of the data. Only member functions can assign and retrieve values of these data members.

Answered by: Sandhya.Kishan on: May 29th, 2012

The data members of the hashtable class stored in the priVATe access specifier as members can be used by the class itself or by friends.It ensure data integrity.If the members are declared as private then only mamber functions can assign and retrive values.

Data structure for one million named objects

Asked By: bitsbyter | Asked On: Sep 17th, 2008

If you have one million named objects and you want to store them in a data structure that lets you insert new objects quickly and search for an object by name quickly, what data structure should you use?

Star Read Best Answer

Editorial / Best Answer

Answered by: hrshksh

View all answers by hrshksh

Member Since May-2010 | Answered On : May 9th, 2010

It depends on the amount of primary memory one has for the process. If we can store 1 million records in primary memory, then we can very well take a hash table with a consistent hashing scheme for avoiding collisions. It will take O(1). 


In most cases however this is not possible. In circumtances like this, there are two ways:
B Trees or Extensible Hashing both of them have interesting time complexities.


Answered by: ptmich on: May 28th, 2012

You can use a hash table or an array of objects You can use an array of objects because you already know that you need to store a specified number of objects, also you can store and access objects qu...

Answered by: hrshksh on: May 9th, 2010

It depends on the amount of primary memory one has for the process. If we can store 1 million records in primary memory, then we can very well take a hash table with a consistent hashing scheme for av...

Stack using two queues

Asked By: waytorooney | Asked On: Sep 29th, 2011

Write a code how to implement stack using two queues? and vice versa ?

Answered by: ptmich on: May 28th, 2012

"c 1.queue_t q0; 2.queue_t q1; 3. 4.void stack_push(void *t) { 5. // At any given time one queue will be empty 6. queue_t *curr = (q0.isEmpty() ? q1 : q0); 7. 8. curr.push(t);...

Answered by: ilushka on: Nov 3rd, 2011

something like this:"c queue_t q0; queue_t q1; void stack_push(void *t) { // At any given time one queue will be empty queue_t *curr = (q0.size() ? q0 : q1); curr.push(t); ...

Conceptually, a linked list queue is the same as a queue built using an array.

Asked By: Interview Candidate | Asked On: Dec 10th, 2005

Skill/topic: queues using linked listsa) trueb) falseexplanation: conceptually, a linked list queue is the same as a queue built using an array. Both store data. Both place data at the front of the queue and remove data from the front of the queue

Answered by: ptmich on: May 28th, 2012

A FIFO (first in, first out) structure means data is added to the back of the queue and removed from the front of the queue. A first in first out structure is equivalent to last in last out structure,...

Answered by: Sandhya.Kishan on: May 15th, 2012

A queue built using array is same as a linked list queue because both insert the data in the front and delete the data from front of the queue,i.e,both follow fifo data structure.

Why is it important to enhance the functionality of the linkedlist class?

Asked By: Interview Candidate | Asked On: Dec 10th, 2005

Skill/topic: stacks and queues: insert, delete, peek, finda) you enhance the functionality of linkedlist class to more easily manipulate a linked list

Answered by: Sandhya.Kishan on: May 19th, 2012

To increase the efficiency of the linkedliss class and to allow easy manipulations on the linked list we should enhance the functionality of the class.

The removenodeat() function removes a node by using the node’s index?

Asked By: Interview Candidate | Asked On: Dec 10th, 2005

Skill/topic: stacks and queues: insert, delete, peek, finda) trueb) falseexplanation: the removenodeat() function removes a node by using the node’s index rather than the reference to the node in memory

Answered by: Sandhya.Kishan on: May 19th, 2012

True, the removenodeat() function removes a node by using the nodes index and not by the the reference to the node in memory.

First | Prev | | Next | Last Page

 

 

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.