Top C & Data Structures Interview Questions Part – 2

Compare And Contrast Compilers From Interpreters.
Compilers and interpreters often deal with how program codes are executed. Interpreters execute program codes one line at a time, while compilers take the program as a whole and convert it into object code, before executing it.
The key difference here is that in the case of interpreters, a program may encounter syntax errors in the middle of execution, and will stop from there. On the other hand, compilers check the syntax of the entire program and will only proceed to execution when no syntax errors are found.
How Do You Declare A Variable That Will Hold String Values?
The char keyword can only hold 1 character value at a time. By creating an array of characters, you can store string values in it.
Example:
“char MyName[50]; ” declares a string variable named MyName that can hold a maximum of 50 characters.
Can The Curly Brackets { } Be Used To Enclose A Single Line Of Code?
While curly brackets are mainly used to group several lines of codes, it will still work without error if you used it for a single line. Some programmers prefer this method as a way of organizing codes to make it look clearer, especially in conditional statements.
What Are Header Files And What Are Its Uses In C Programming?
Header files are also known as library files. They contain two essential things: the definitions and prototypes of functions being used in a program. Simply put, commands that you use in C programming are actually functions that are defined from within each header files.
Each header file contains a set of functions. For example: stdio.h is a header file that contains definition and prototypes of commands like printf and scanf.
What Is Syntax Error?
Syntax errors are associated with mistakes in the use of a programming language. It maybe a command that was misspelled or a command that must was entered in lowercase mode but was instead entered with an upper case character. A misplaced symbol, or lack of symbol, somewhere within a line of code can also lead to syntax error.
What Are Variables And It What Way Is It Different From Constants?
Variables and constants may at first look similar in a sense that both are identifiers made up of one character or more characters (letters, numbers and a few allowable symbols). Both will also hold a particular value. Values held by a variable can be altered throughout the program, and can be used in most operations and computations.
Constants are given values at one time only, placed at the beginning of a program. This value is not altered in the program. For example, you can assigned a constant named PI and give it a value 3.1415 . You can then use it as PI in the program, instead of having to write 3.1415 each time you need it.
What Is Data Structure?
Data structure is a group of data elements grouped together under one name.
These data elements are called members. They can have different types and different lengths.
Some of them store the data of same type while others store different types of data.
Explain The Types Of Data Structures
There are two basic types of data structures:
linear.
nonlinear.
Linear data structures :
Linear data structures are organized in a way similar to the way computer memory is organized. Linear data structures store elements one after the other, in a linear fashion. Only one element of the data can be traversed at a time. Imagine a stack of books placed on a shelf.
A book will be placed between two other books, but not three books- a book will only have a relationship to two other books at the most at one time. Linear data elements are stored in a similar way.
Non linear data structures :
Non linear data structures are stored in a sequential way. The data elements in the non linear data structures may have relationships with one or more elements at the same time. Manipulating non linear data structures is more difficult than manipulating linear data structures.
List Out The Areas In Which Data Structures Are Applied Extensively?
Compiler Design.
Operating System.
Database Management System.
Statistical analysis package.
Numerical Analysis.
Graphics.
Artificial Intelligence.
Simulation.
Differentiate File Structure From Storage Structure.
Basically, the key difference is the memory area that is being accessed. When dealing with the structure that resides the main memory of the computer system, this is referred to as storage structure. When dealing with an auxiliary structure, we refer to it as file structure.
Which Data Structure Is Used To Perform Recursion?
The data structure used for recursion is Stack.
Its LIFO property helps it remembers its ‘caller’. This helps it know the data which is to be returned when the function has to return.
System stack is used for storing the return addresses of the function calls.
What Is A Linked List?
A linked list is a set of linear elements where each element has an index or a pointer that indicates the next element. An element of a linked list is referred to as a node. A node will store data as well as a pointer/index about the next node in the set. There are different types of linked lists.
For example, a circular linked list is a list where the last element of the list points to the first element of the list, forming an unbroken chain of data. A double linked list is a list in which every node stores the index of the node on either side of it.
What Are The Major Data Structures Used In The Following Areas ?
RDBMS, Network data model and Hierarchical data model.
RDBMS =
Array (i.e. Array of structures)
Network data model =
Graph
Hierarchical data model =
Trees
What Is Lifo?
LIFO is short for Last In First Out, and refers to how data is accessed, stored and retrieved. Using this scheme, data that was stored last , should be the one to be extracted first. This also means that in order to gain access to the first data, all the other data that was stored before this first data must first be retrieved and extracted.
Does The Minimal Spanning Tree Of A Graph Give The Shortest Distance Between Any 2 Specified Nodes?
No, it doesn’t.It assures that the total weight of the tree is kept to minimum.It doesn’t imply that the distance between any two nodes involved in the minimum-spanning tree is minimum.
What Is A Queue?
A queue is a collection of data that follows the FIFO (First in First Out) principle. It is a type of a linear data structure. Elements in a queue are removed only from the front, while new elements are added only at the back of a queue. Imagine a queue of people in front of movie theater for tickets.
People can’t skip to the front for tickets – they have to join the back of the queue. People leave the queue only after they get their tickets, from the front. This is a great example of a queue in data structures. The two operations performed on a queue are enqueue (adding data elements) and dequeue(removing data elements).
A priority queue is a queue in which every element in the queue is assigned a priority and operations are performed on it according to this priority.
If You Are Using C Language To Implement The Heterogeneous Linked List, What Pointer Type Will You Use?
The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.
What Are Multidimensional Arrays?
Multidimensional arrays make use of multiple indexes to store data. It is useful when storing data that cannot be represented using a single dimensional indexing, such as data representation in a board game, tables with data stored in more than one column.
Minimum Number Of Queues Needed To Implement The Priority Queue?
Two. One queue is used for actual storing of data and another for storing priorities.
Are Linked Lists Considered Linear Or Non-linear Data Structure?
It actually depends on where you intend to apply linked lists. If you based it on storage, a linked list is considered non-linear. On the other hand, if you based it on access strategies, then a linked list is considered linear.
Differentiate Between Push And Pop?
Pushing and popping refers to the way data is stored into and retrieved from a stack.
PUSH –
Data being pushed/ added to the stack.
POP –
Data being retrieved from the stack, particularly the topmost data.
What Are The Notations Used In Evaluation Of Arithmetic Expressions Using Prefix And Postfix Forms?
Polish and Reverse Polish notations.
How Does Dynamic Memory Allocation Help In Managing Data?
Aside from being able to store simple structured data types, dynamic memory allocation can combine separately allocated structured blocks to form composite structures that expand and contract as needed.
When Is A Binary Search Algorithm Best Applied?
It is best applied to search a list when the elements are already in order or sorted.
The list here is searched starting in the middle. If that middle value is not the correct one, the lower or the upper half is searched in the similar way.
In Rdbms, What Is The Efficient Data Structure Used In The Internal Storage Representation?
B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes.
What Is A Spanning Tree?
A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.
Does The Minimum Spanning Tree Of A Graph Give The Shortest Distance Between Any 2 Specified Nodes?
No. The Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn’t mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.
Which Is The Simplest File Structure? (sequential, Indexed, Random)
Sequential is the simplest file structure.
Whether Linked List Is Linear Or Non-linear Data Structure?
According to Access strategies Linked list is a linear one.
According to Storage Linked List is a Non-linear one
In Tree Construction Which Is The Suitable Efficient Data Structure? (array, Linked List, Stack, Queue)
Linked list is the suitable efficient data structure.
What Is The Type Of The Algorithm Used In Solving The 8 Queens Problem?
Backtracking.
List Out Few Of The Applications That Make Use Of Multilinked Structures?
Sparse matrix.
Index generation.
What Are The Types Of Collision Resolution Techniques And The Methods Used In Each Of The Type?
Open addressing (closed hashing), The methods used include: Overflow block.
Closed addressing (open hashing), The methods used include: Linked list, Binary tree.
Sorting Is Not Possible By Using Which Of The Following Methods? (insertion, Selection, Exchange, Deletion)
Sorting is not possible in Deletion. Using insertion we can perform insertion sort, using selection we can perform selection sort, using exchange we can perform the bubble sort (and other similar sorting methods). But no sorting method can be done just using deletion.
What Are The Methods Available In Storing Sequential Files?
Straight merging.
Natural merging.
Polyphase sort.
Distribution of Initial runs.
List Out Few Of The Application Of Tree Data-structure?
The manipulation of Arithmetic expression.
Symbol Table construction.
Syntax analysis.

Related

Interview Questions 4892014558365604048

Post a Comment

emo-but-icon

item