Showing posts with label frequently interview questions. Show all posts
Showing posts with label frequently interview questions. Show all posts

Linked Lists in Programming


Arrays are quite useful in all programming languages. However, they also have some limitations. They require creating a new array with bigger size and copying the existing elements from the old array to the new one when the capacity of an array is overrun. Additionally, they have to shift some elements in an array when a new element is inserted because memory of an array is sequentially allocated. Such limitations can be overcome by dynamic structures, such as linked lists.It is not necessary to know the size of a list when it is created, so it is treated as a dynamic data structure. Rather than allocate memory for all elements when a list is initialized, memory is allocated for each node on demand when it is inserted. The space efficiency of lists is better than arrays because there is no vacant memory in lists.Memory allocation of a list is not continuous because nodes are inserted dynamically and their memory is not allocated at the same time. It costs O(n) time to get the ith node in a list since it has to traverse nodes one by one starting from the head node. It only takes O(1) time to get the ith element in an array. Therefore, time efficiency to search lists is not as good as for arrays.
Linked lists are the most frequently met data structures during interviews. It only takes about 20 lines of code to create a list, insert a node into a list, or delete a node from a list. Compared to other complex data structures, such as hash tables and graphs, lists are more suitable for interviews due to their moderate code size. Additionally, lots of pointer operations are required to handle a list. Candidates without qualified programming abilities cannot implement complete and robust code related to lists. Moreover, lists are also flexible and challenging interview questions can be constructed with them. Therefore, many interviewers like questions related to lists.
Most lists met during interviews are single-linked lists, where each node has a link to its successor. For example, “Print a List from Tail to Head”, “Delete a Node from a List in O(1) Time”, “kth Node from the End”, “Reverse Lists”, and “First Intersection Node of Two Lists" are all about single-linked lists.
Not only are single-linked lists popular for interviews, but other types of lists are also frequently met:
  • Usually the tail node in a single-linked list does not have a successor. If every node in a finite list has a successor, a loop is formed. The section Loop in List discusses lists with loops.
  • If there is also a link to a predecessor besides a link to a successor in each node of a list, it is a double-linked list. The interview question “Binary Search Trees and Double-Linked Lists” is in this category.
  • A complex list is composed if each node has a link to any other node (including the node itself). Please refer to the interview question “Clone Complex Lists” for more details on the complex list.
www.cinterviews.com appreciates your contribution please mail us the questions you have to cinterviews.blogspot.com@gmail.com so that it will be useful to our job search community

Data Structures interview point of you

 Data Structures

The primary purpose of most computer programs is to store, retrieve, and process information. Consequently, data structures and algorithms that manipulate information of computer science. For this reason, many interviewers often focus a number of their questions on these aspects. we will cover typical interview questions about the most common data structures, including arrays, strings, lists, trees, stacks, and queues.
Arrays
Arrays might be the most simple data structure. Elements are sequentially stored in continuous memory in arrays. When an array is created, its size should be specified. Even though it may only store one element at first, the size is required because we have to allocate memory for all of the elements. Since there may be vacancies in arrays, they are not efficient in memory utilization.
In order to improve space efficiency, dynamic arrays were developed. The class vector in the standard template library (STL) of C++ is one such example. Memory is allocated for a few elements in dynamic arrays at first. When the number of elements is greater than the capacity of a dynamic array, more memory is allocated (the capacity doubles when it has to enlarge the capacity of a vector in C++), existing elements are copied to the newly allocated space, and the previous memory is released. It reduces waste in memory, but many extra operations are required to enlarge capacity, so it has negative impact on time efficiency. Therefore, it is better to reduce the times needed to enlarge the capacity of dynamic arrays. The type ArrayList in both C# and Java is similar to vector in C++.
Because memory allocation for arrays is sequential, it only costs O(1) time to access to an element based on its index, and it is very efficient. A simple hash table can be implemented with an array to utilize its advantage of time efficiency. Each index is treated as a key and every element in an array is treated as a value, so an index and its corresponding element form a pair of key and value. Many problems can be solved with such a hash table, and examples are illustrated in the section Hash Tables for Characters. It is a practical solution especially when built-in hash tables are not available in some programming languages such as C/C++.
Arrays and pointers are closely related to each other in C/C++ and also different from each other. The C code in Listing 3-1 shows the relationship between them. What is the output of this code?
Listing 3-1. C Code about Arrays and Pointers
int GetSize(int data[]) {
    return sizeof(data);
}
int _tmain(int argc, _TCHAR* argv[]) {
int data1[] = {1, 2, 3, 4, 5};
    int size1 = sizeof(data1);
 int* data2 = data1;
    int size2 = sizeof(data2);
    int size3 = GetSize(data1);
    printf("%d, %d, %d", size1, size2, size3);
}
The output should be “20, 4, 4” in a 32-bit system. data1 is an array, and sizeof(data1) gets its size. There are five integers in the array, and each integer occupies four bytes, so the total size of array is 20 bytes.
The name of an array is the address of the first element in the array, so data2 points to the first element of an array with the statement data2 = data1. data2 is declared as a pointer, and the sizeof operator returns 4 for any pointers in a 32-bit system.
When an array is passed as a parameter in C/C++, the compiler treats it as a pointer. What gets passed is the address of the first element in an array, rather than the whole array. Therefore, the result of sizeof(data) is also 4 in the function GetSize even though data is declared as an array in the parameter list.
 
www.cinterviews.com appreciates your contribution please mail us the questions you have to cinterviews.blogspot.com@gmail.com so that it will be useful to our job search community

most interview faqs

Most frequently asked Interview Questions

* Why have you selected to join us?
I always longed to work with a company. I am familiar and whose products I have used and trusted.
(Narrate briefly how you can prove your statement. Do good research on the company before facing the interview)
* Where do you want to be in 5 years?
I would like to be frank. Judge me from the work and I am sure you will put me right where I want to be.
Note : Do not over ambitious and speak in a way that you are not satisfied with your current job which you have applied for.
* Describe your ideal career?
Talk of what you enjoy most your skills and natural talents. Do not specify your goal and any job title.
* Tell me something about yourself
Do not just repeat what you have given in your resume. Be ready with the answer, a talent or something you did out of the ordinary. You can sound it as unique or give it a touch of your personality.
* How did you apply for the job?
Be specific and give a straight answer of how you came to know about the vacancy. If it was advertised specify how you came across it.
* Why do you want to work here?
Have a research done about the company / organization
Give just one or two reasons why you are interested. You can add these points (1) company's reputation(2) desire to join the specific field of interest.
* Don't you think that you are over qualified for this job?
(This question is put to you to puzzle a candidate. Be calm and answer the question with a positive and confident approach)
Answer in the negative
My experience and qualification will just help me to do the job better. Moreover I am at establishing a long term relationship which my qualification will favor me to handle more responsibilities and help me to rise to your expectations.
* What competition do you see if you take up this job?
When you answer, clearly show that you have researched carefully and acquired more in-depth knowledge about the company.
Enumerate some positive and negative traits of the company and their competitions.
Feel confident to show that competition is not an unexpected one.
* What would you do if our competitor offer you a job?
Show your confidence in the company's worth, stress the point 'I would say No' by pointing out some qualities you found out in your research about the company.
* Why are you leaving your current job?
You should give two or three reasons for leaving.
Lack of challenge, focus on the limitations etc. Point out your ambition to prove your worth confidently.
* What salary do you expect?
(This is a tricky question to be answered carefully. Interviewers often accept people with realistic financial goals.)
If you mention a salary that is low it shows that you are not up to the mark. If you mention too high you have ruined a chance to get a job. So the best is to ask for the salary they offer and then show your capacity, how your experience and qualification rate with what is offered.
* What interests you most about the job?
(Show how you believe that you are most suited to the post. If you can find out an earlier experience it would be fine.)
If you have experience, you can quote some similarities from the past and how you achieved success.
* What is your dream job?
Make the question a chance to display your aptitude that fits the job you have applied for. Display how your skills can be put into suite the challenges and modern trends.
* Why should we take you?
This is often the concluding Question( Some tips to the answer)
* Don'ts : Do not repeat your resume
Do not enumerate your experience
* Do's: Prove Your interest
Be positive in your answer
Be prepared with confidence in what you are going to say
Make sure the answer comes from the bottom of your heart.
* If you have unlimited time and financial resources
how would you spend them
Even though it is tempting to discuss thing you would do for fun, answer these questions with strict coherence with the job you have applied for.
Egg: If you are into teaching, touch on your interest in adult literary programmers and other teaching oriented aspects.
* How is your experience relevant to this job?
Sketch out some similar work which you have done in your previous job. It should be something justifiable by you, even though others may think differently.
You can even ask some question where you can prove that your experience stands in good strand.
* How could you enrich your current job?
Design your answer to show that you are still interested in the job and you point out a few instances where improvements can be made. Convince the person that you can be relied on and you will not get bored with what you do with time.
* How many days where you absent from work?
Give a solid attendance record. But at the same time show you were not responsible . Convince that you are willing to take up responsibility.
Egg: I was absent 7 days. 4 days due to conjunctivitis and one day due to the death of a close relative and 2 days had to accompany my parents for their check up.
* Tell me about a time you had to deal with an irritate customer, how did you handle the solution?
The question is aimed at you to hear from yourself how you handle people when others loose their temper. Here the best answer you can give to describe a situation and show how you handled it with maturity and diplomacy.
* How do you manage stress in your daily work?
You can describe a situation of how you had managed stress in your previous work if you had one or narrate how you can find time in your busy schedule to relax a bit.
* Describe a professional skill you have developed in you?
It will be better if you be specific with your answer. Narrate some thing you worked for to fulfill your work more efficiently. Describe how you attended a seminar
and brought about the changed in your work.
* How do you manage your work to meet dead lines
Answer the question effectively . Describe in detail how your plan out, set priorities, determine schedules, how you follow out to see the progress and meet the dead line.
* What books you read?
Do not ever say you have read a book which you have not. Here your suggestion can lead the interviewer to know your taste and interest. It can also hint on how you take your profession.
* What are the most rewarding aspect of you most recent job?
The best way to answer it is to focus in what you do efficiently, keep in mind the position you are applying for.
* What aspects of this job do you feel most confident?
Narrate what you are good and match it with the present job requirements. You may ask questions to clear if that particular skill will add benefit to the company
* What can motivate you?
The Interview expects an answer to know you better .Keep in tune with your job and work you have applied for. Do not beat around the bush.
* Whom do you choose as your reference and why?
Name the references and how you know them. You can also show that you are a person who care for relationships and how you stand in good stead with them.
* Can we call all your references?
If you have given your present boss as your reference you can tell that you prefer to call your current boss only after you receive a confirmed offer as he may not like you changing the job.
* Do you have any questions?
Be prepared to answer this question in advance. List out a few questions you wish to know more about. After you have faced the interview your logic will guide you to ask the question you really want to know more about.
* How do you handle criticism
Here the interview is on the look out for your accountability and professional character.
Simply explain a situation that caused a problem and narrate how you faced it and overcame it.
* Tell me about a situation that upset you at work
Her the interview is trying to find out how you deal with pressure. Be diplomatic and objective with your answer. Prepare the answer so that the answer comes as a smooth reassurance
* Have you ever been fired?
If the answer is negative, the answer is simple. But if you have been fired, you need to be prepared to the answer the follow up questions that my come up.
If the termination was for reason beyond your control narrate it. If not do not try justifying yourself. If you had a fault, admit it and convince the interview that you have corrected it.
* Do you change your job frequently?
Be honest and if you had changed the jobs frequently there could be ample reasons to do so. Put them up as contracts that expired at the stipulated time.
Be convincing when you say that you long to have a steady and long lasting relationship with the present job you are applying for.
* What is the toughest job you had?
Avoid making any negative statements especially about your previous employer. Change the question with a positive outlook and answer it with a satisfied remark of your outcome.
* How do you handle tension?
Answer with ease that in any job and any situation that tension is a part of it. Relax before putting the f act you are very used to such type of works.
* What is your current salary?
Do not bluff. Be specific on the answer. Do not hesitate to say the benefits you enjoyed in the previous job. It may be verified so never mention the benefits you have not got.
* Will you be willing to accept transfer?
Tell you preference but do not specify that you will be not willing to work else where.
* What is your weakness?
Turn the question to a positive one. Simply say that you are a perfectionist and your commitment to output of high quality perfect work. Say this is your weakness.