You are on page 1of 23

Microprocessor

What is a Microprocessor? Microprocessor is a program-controlled device, which fetches the instructions from memory, decodes and executes the instructions. Most Micro Processor are single- chip devices. What is the difference between microprocessor and microcontroller? The major difference is microprocessor doesnt have inbuilt memory but micro-controller has inbuilt memory .In Microprocessor more op-codes, few bit handling instructions. But in Microcontroller: fewer op-codes, more bit handling Instructions. Micro-controller can be defined as a device that includes micro processor, memory, & input / output signal lines on a single chip. Give examples for 8 / 16 / 32 bit Microprocessor? 8-bit Processor - 8085 / Z80 / 6800; 16-bit Processor - 8086 / 68000 / Z8000; 32-bit Processor - 80386 / 80486. Why 8085 processor is called an 8 bit processor? Because 8085 processor has 8 bit ALU (Arithmetic Logic Review). Expand HCMOS? High-density n- type Complimentary Metal Oxide Silicon field effect transistor. What does microprocessor speed depend on? The processing speed depends on DATA BUS WIDTH. What is the Maximum clock frequency in 8086? 5 Mhz is the Maximum clock frequency in 8086 Is the address bus unidirectional? Is the data bus is Bi-directional? The address bus is unidirectional because the address information is always given by the Micro Processor to address a memory location of an input / output devices. The data bus is Bi-directional because the same bus is used for transfer of data between Micro Processor and memory or input / output devices in both the direction. What is the disadvantage of microprocessor? It has limitations on the size of data. Most Microprocessor does not support floating-point operations. What is the difference between primary & secondary storage device? In primary storage device the storage capacity is limited. It has a volatile memory. In secondary storage device the storage capacity is larger. It is a nonvolatile memory. Primary devices are: RAM / ROM. Secondary devices are: Floppy disc / Hard disk. Difference between SRAM and DRAM?

Static RAM: No refreshing, 6 to 8 MOS transistors are required to form one memory cell, Information stored as voltage level in a flip flop. Dynamic RAM: Refreshed periodically, 3 to 4 transistors are required to form one memory cell, Information is stored as a charge in the gate to substrate capacitance. What is an interrupt? Interrupt is a signal send by external device to the processor so as to request the processor to perform a particular work. What are the different types of interrupts? Maskable and Non-maskable interrupts. What is cache memory? Cache memory is a small high-speed memory. It is used for temporary storage of data & information between the main memory and the CPU (center processing unit). The cache memory is only in RAM. Expand DMA? Direct Memory Access Differentiate between RAM and ROM? RAM: Random Access Memory. Read / Write memory, High Speed, Volatile Memory. ROM: Read only memory, Low Speed, Non Volatile Memory What is NV-RAM? Nonvolatile Read Access Memory, also called Flash memory. What is a flag? Flag is a flip-flop used to store the information about the status of a processor and the status of the instruction executed most recently What are the flags in 8086? In 8086 Carry flag, Parity flag, Auxiliary carry flag, Zero flag, Overflow flag, Trace flag, Interrupt flag, Direction flag, and Sign flag. What is meant by Maskable interrupt? An interrupt that can be turned off by the programmer is known as Maskable interrupt. What is Non-Maskable interrupt? An interrupt which can be never be turned off (ie.disabled) is known as Non-Maskable interrupt. Which interrupts are generally used for critical events? Non-Maskable interrupts are used in critical events. Such as Power failure, Emergency, Shut off etc. Give examples for Maskable interrupts?

RST 7.5, RST6.5, RST5.5 are Maskable interrupts Give example for Non-Maskable interrupts? Trap is known as Non-Maskable interrupts, which is used in emergency condition. What are the various segment registers in 8086? Code, Data, Stack, Extra Segment registers in 8086. Which Stack is used in 8086? FIFO (First In First Out) stack is used in 8086.In this type of Stack the first stored information is retrieved first. What is SIM and RIM instructions? SIM is Set Interrupt Mask. Used to mask the hardware interrupts. RIM is Read Interrupt Mask. Used to check whether the interrupt is Masked or not. What is Tri-state logic? Three Logic Levels are used and they are High, Low, High impedance state. The high and low are normal logic levels & high impedance state is electrical open circuit conditions. Tri-state logic has a third line called enable line. Give an example of one address microprocessor? 8085 is a one address microprocessor. In what way interrupts are classified in 8085? In 8085 the interrupts are classified as Hardware and Software interrupts. What are Hardware interrupts? TRAP, RST7.5, RST6.5, RST5.5, INTR. What are Software interrupts? RST0, RST1, RST2, RST3, RST4, RST5, RST6, RST7. Which interrupt has the highest priority? TRAP has the highest priority. Name 5 different addressing modes? Immediate, Direct, Register, Register indirect, Implied addressing modes. How many interrupts are there in 8085? There are 12 interrupts in 8085. What is the RST for the TRAP? RST 4.5 is called as TRAP.

In 8085 which is called as High order / Low order Register? Flag is called as Low order register & Accumulator is called as High order Register.

32-bit versus 64-bit As the number of bits increases there are two important benefits. y y More bits means that data can be processed in larger chunks which also means more accurately. More bits means our system can point to or address a larger number of locations in physical memory. 32-bit systems were once desired because they could address (point to) 4 Gigabytes (GB) of memory in one go. Some modern applications require more than 4 GB of memory to complete their tasks so 64-bit systems are now becoming more attractive because they can potentially address up to 4 billion times that many locations. Since 1995, when Windows 95 was introduced with support for 32-bit applications, most of the software and operating system code has been 32-bit compatible.

Software Engineering Interview Question and Answers


1. Define software engineering?

According to IEEE, Software engineering is the application of a systematic, disciplined, quantifiable approach to the development, operation and maintenance of sofware.
2. What are the categories of software? System software Application software Embedded software Web Applications Artificial Intelligence software Scientific software. 3. Define testing?

Testing is a process of executing a program with the intent of finding of an error.


4. What is white box testing?

White box testing is a test case design method that uses the control structure of the procedural design to derive test cases. It is otherwise called as structural testing.
5. What is Black box testing?

Black box testing is a test case design method that focuses on the functional requirements of the software. It is otherwise called as functional testing.
6. What is verification and validation? Verification refers to the set of activities that ensure that software correctly implements a specific function.

Validation refers to the set of activities that ensure that the software that has been built is traceable to customer requirements. 7. What is debugging?

Debugging is the process that results in the removal of error. It occurs as a consequence of successful testing. 8. Define cyclomatic complexity? Cyclomatic complexity is a software metric that provides a quantitative measuer of the logical complexity of a program. 9. What is error tracking? Error tracking is an activity that provides a means for assessing the status of a current project. 10. What are case tools? Computer Aided Software Engineering - CASE tools assist software engineering managers and practitioners in evey activity associated with the software process. They automate project management activities manage all work products produced throughout the process and assist the engineers in their analysis, design, coding and test work. 11. What is data design? Data design transforms the information domain model created during analysis into the data structures that will be required to implement the software. 12. Define cohension and coupling? Cohension is a measure of the relative functional strength of a module.

Coupling is a measure of the relative interdependence among modules. 13. What are the different types of cohension? There are different types of cohension are

Coincidental cohension Logical cohension Temporal cohension Procedural cohension Communicational cohension 14. What are the different types of coupling?

There are different types of coupling are

Data coupling Stamp coupling Control coupling External coupling Common coupling Content coupling 15. What is user interface design? User interface design creates an effective communication medium between a human and a computer. 16. What is meant by specification? A specification can be a written document, a graphical model, a formal mathematical model, a collection of usage scenarios, a prototype or any combination of these. 17. Define process? A series of steps involving activities, constraints, and resources that produce an intended output of some kind is known as process. 18. How spiral model works? The spiral model is an evolutionary software process model that couples the iterative nature of prototyping with the controlled and systematic aspects of the waterfall lifecycle model. It also has an emphasis on the use of risk management techniques. 19. What is winwin spiral model? Winwin spiral model defines a set of negotiation activities at the beginning of each pass around the spiral. The best negotiations strive for a win-win result. 20. Mention the various views in system engineering hierarchy? The various views in system engineering hierarchy from top to bottom in order are

World view Domain view Element view

Detailed view 21. What is software requirements definition? A software requirements definition is an abstract description of the services which the system should provide and the constraints under which the system must operate. 22. What is SDLC ? A software cycle deals with various parts and phases from planning to testing and deploying. All these activities are carried out in different ways, as per the needs. Each way is known as a Software Development Lifecycle Model (SDLC). 23. What are data aquistion systems? Systems that collects data from sensors for subsequent processing and analysis are termed as Data acquistion systems. Data collection process and processing processes may have different periods and deadlines. 24. Define software configuration model? SCM is the art of identifying, organizing, and controlling modifications to the software being built by a programming team. It is an umbrella activity that is applied throughout the software process. 25. What are the SCM activities? SCM activities are developed to

Identify change Control change Ensure that change is being properly implemented Report changes to others who may have an interest. 26. What are the advantages and disadvantages of white box testing? Advantages : Softwares structure logic can be tested.

Disadvantages : Doesnt ensure that user requirements are met. Its test may not mimic real world situations.

27.

What is meant by loop testing? Loop testing is a white box testing techniques that focuses exclusively on the validity of loop constructs. This technique can be applied to simple loops, nested loops, concatenated loops and unstructured loops.

28.

What is meant by smoke testing? Smoke testing is an integration testing approach that is commonly used ehen shrink wrapped software products are being developed.

29.

What is alpha and beta tests? Alpha test is the test that is conducted at the developers site by a customer. Beta test is the test that is conducted at one or more customer sites by the end-user of the software.

30.

What is meant by system testing? System testing is actually a series of different tests whose primary purpose is to fully exercise the computer based system. It verifies whether the system elements have been properly integrated and perform the allocated functions.

31. Mention the categories of debugging approaches? There are three categories of debugging approaches as follows : Brute force Back tracking Cause elimination 32. Define metric? IEEE93 defines as a quantitative measure of the degree to which a system, componen, or process possesses a given attribute. 33. Mention some of the process models appropriate for the software to be engineered? Linear sequential or waterfall model Prototyping model Rad model

Incremental model Spiral model Winwin spiral model Component based development model 34. What is adaptive maintenance? Adaptive maintanence is the maintenance to adapt software to a different operating environment. It involves changing a system so that it operates in a different environment from its initial implementation. 35. What are the advantages and disadvantages of black box testing? Advantages: Simulates actual system usage. makes no system structure assumptions. Disadvantages : Potential of missing logical errors in software. Possibility of redundant testing.
36. What are the broad categories of system requirements? System requirements may be either functional or non-functional requirements. 37. What are user requirements? User requirements should describe functional and non-functional requirements so that they are understandable by system users who dont have detailed technical knowledge. User requirements are defined using natural language, tables and diagrams. 38. What is test scenario ? Test scenario is the hypothetical story to test the particular functionality of an application. It serves as an input to functional testing. For test scenario we need use case. 39. Define an analysis model? An analysis model is a set of models that serves as the technical representation of system.

40.

Define prototype? Prototype is an initial version of a software system which is used to demonstrate concepts, try out design options and generally to find out more about the problem and its possible solutions.

41.

What is the function of the user model? The user model establishes the profile of end users of the system.

42.

What is system image? The system image combines the outward manifestation of the computer based system, coupled with all supporting information that describes system syntax and semantics.

43.

what is transform mapping? Transform mapping is a set of design steps that allows a DFD with transform flow charactersistics to be mapped into a specific architectural style.

44.

What is tracebility matrix? Traceability matrix is a document in which we map the test cases with the requirements. In general we check whether the application works as per requirements or whether we had covered all the required functionality through test cases.

45.

List the metrics for specifying non functional requirements? The possible metrics that specify the non-functional requirements are :

Speed Size Easy of use Reliability 46. What is the difference between black box testing and white box testing? Black box testing : No knowledge of the internal logic of the system is used to develop test cases. Uses validation techniques. Applied during later stages of testing. Examples include unit testing, integration testing, system testing, acceptance

testing. White box testing :

Uses verification techniques Performed early in the testing process. 47. Mention the various types of maintenance? The various types of maintenance are :

Corrective maintenance Adaptive maintenance Perfective maintenance Preventive maintenance 48. What is the difference between software engineering and system engineering? System Engineering - is concerned with all aspects of computer based systems development including hardware, software and process engineering.

System Engineering - are involves in system specification architectural design intergration and deployment.

nowledge of the internal logic of the system is used to develop test cases.

Data Structures Interview Questions and Answers


What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data. 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 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 is the data structures used to perform recursion? Stack. Because of its LIFO (Last In First Out) property it remembers its caller, so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls. Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used. 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. 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? 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 minimumspanning tree is minimum.

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. What is the quickest sorting method to use? The answer depends on what you mean by quickest. For most sorting problems, it just doesn't matter how quick the sort is because it is done infrequently or other operations take significantly more time anyway. Even in cases in which sorting speed is of the essence, there is no one answer. It depends on not only the size and nature of the data, but also the likely order. No algorithm is best in all cases. There are three sorting methods in this author's toolbox that are all very fast and that are useful in different situations. Those methods are quick sort, merge sort, and radix sort.

The Quick Sort The quick sort algorithm is of the divide and conquer type. That means it works by reducing a sorting problem into several easier sorting problems and solving each of them. A dividing value is chosen from the input data, and the data is partitioned into three sets: elements that belong before the dividing value, the value itself, and elements that come after the dividing value. The partitioning is performed by exchanging elements that are in the first set but belong in the third with elements that are in the third set but belong in the first Elements that are equal to the dividing element can be put in any of the three sets the algorithm will still work properly. The Merge Sort The merge sort is a divide and conquer sort as well. It works by considering the data to be sorted as a sequence of already-sorted lists (in the worst case, each list is one element long). Adjacent sorted lists are merged into larger sorted lists until there is a single sorted list containing all the elements. The merge sort is good at sorting lists and other data structures that are not in arrays, and it can be used to sort things that don't fit into memory. It also can be implemented as a stable sort. The Radix Sort The radix sort takes a list of integers and puts each element on a smaller list, depending on the value of its least significant byte. Then the small lists are concatenated, and the process is repeated for each more significant byte until the list is sorted. The radix sort is simpler to implement on fixed-length data such as ints.
How can I search for data in a linked list? Unfortunately, the only way to search a linked list is with a linear search, because the only way a linked list's members can be accessed is sequentially. Sometimes it is quicker to take the data from a linked list and store it in a different data structure so that searches can be more efficient. What is the heap? The heap is where malloc(), calloc(), and realloc() get memory.

Getting memory from the heap is much slower than getting it from the stack. On the other hand, the heap is much more flexible than the stack. Memory can be allocated at any time and deallocated in any order. Such memory isn't deallocated automatically; you have to call free(). Recursive data structures are almost always implemented with memory from the heap. Strings often come from there too, especially strings that could be very long at runtime. If

you can keep data in a local variable (and allocate it from the stack), your code will run faster than if you put the data on the heap. Sometimes you can use a better algorithm if you use the heap faster, or more robust, or more flexible. Its a tradeoff. If memory is allocated from the heap, its available until the program ends. That's great if you remember to deallocate it when you're done. If you forget, it's a problem. A memory leak is some allocated memory that's no longer needed but isn't deallocated. If you have a memory leak inside a loop, you can use up all the memory on the heap and not be able to get any more. (When that happens, the allocation functions return a null pointer.) In some environments, if a program doesn't deallocate everything it allocated, memory stays unavailable even after the program ends.
What is the easiest sorting method to use? The answer is the standard library function qsort(). It's the easiest sort by far for several reasons: It is already written. It is already debugged. It has been optimized as much as possible (usually). Void qsort(void *buf, size_t num, size_t size, int (*comp)(const void *ele1, const void *ele2)); What is the bucket size, when the overlapping and collision occur at same time? One. If there is only one entry possible in the bucket, when the collision occurs, there is no way to accommodate the colliding value. This results in the overlapping of values. In an AVL tree, at what condition the balancing is to be done? If the pivotal value (or the Height factor) is greater than 1 or less than 1. 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. How many different trees are possible with 10 nodes ? 1014 - For example, consider a tree with 3 nodes(n=3), it will have the maximum combination of 5 different (ie, 23 - 3 =? 5) trees. What is a node class? A node class is a class that, relies on the base class for services and implementation, provides a wider interface to users than its base class, relies primarily on virtual functions in its public interface depends on all its direct and indirect base class can be understood only in the context of the base class can be used as base for further derivation can be used to create objects. A node class is a class that has added new services or functionality beyond the services inherited from its base class. When can you tell that a memory leak will occur? A memory leak occurs when a program loses the ability to free a block of dynamically allocated memory. What is placement new? When you want to call a constructor directly, you use the placement new. Sometimes you have some raw memory thats already been allocated, and you need to construct an object in the memory you have. Operator news special version placement new allows you to do it. class Widget {

public : Widget(int widgetsize); Widget* Construct_widget_int_buffer(void *buffer,int widgetsize) { return new(buffer) Widget(widgetsize); } }; This function returns a pointer to a Widget object thats constructed within the buffer passed to the function. Such a function might be useful for applications using shared memory or memory-mapped I/O, because objects in such applications must be placed at specific addresses or in memory allocated by special routines.
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 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 is the data structures used to perform recursion? Stack. Because of its LIFO (Last In First Out) property it remembers its caller so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls. Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used. 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


Tell how to check whether a linked list is circular ? Create two pointers, each set to the start of the list. Update each as follows:

while (pointer1) { pointer1 = pointer1->next; pointer2 = pointer2->next; if (pointer2) pointer2=pointer2->next; if (pointer1 == pointer2) ??????{ print (\circular\n\); } }

What is the difference between ARRAY and STACK? STACK follows LIFO. Thus the item that is first entered would be the last removed.

In array the items can be entered or removed in any order. Basically each member access is done using index. No strict order is to be followed here to remove a particular element.
What is the difference between NULL AND VOID pointer? NULL can be value for pointer type variables. VOID is a type identifier which has not size. NULL and void are not same. Example: void* ptr = NULL; What is precision? Precision refers the accuracy of the decimal portion of a value. Precision is the number of digits allowed after the decimal point. What is impact of signed numbers on the memory? Sign of the number is the first bit of the storage allocated for that number. So you get one bit less for storing the number. For example if you are storing an 8-bit number, without sign, the range is 0-255. If you decide to store sign you get 7 bits for the number plus one bit for the sign. So the range is -128 to +127. How memory is reserved using a declaration statement ? Memory is reserved using data type in the variable declaration. A programming language implementation has predefined sizes for its data types.

For example, in C# the declaration int i; will reserve 32 bits for variable i. A pointer declaration reserves memory for the address or the pointer variable, but not for the data that it will point to. The memory for the data pointed by a pointer has to be allocated at runtime. The memory reserved by the compiler for simple variables and for storing pointer address is allocated on the stack, while the memory allocated for pointer referenced data at runtime is allocated on the heap.
How many parts are there in a declaration statement? There are two main parts, variable identifier and data type and the third type is optional which is type qualifier like signed/unsigned. Is Pointer a variable? Yes, a pointer is a variable and can be used as an element of a structure and as an attribute of a class in some programming languages such as C++, but not Java. However, the contents of a pointer is a memory address of another location of memory, which is usually the memory address of another variable, element of a structure, or attribute of a class. What is Data Structure? A data structure is a group of data elements grouped together under one name. These data elements, known as members, can have different types and different lengths. Some are used to store the data of same type and some are used to store different types of data.

What is significance of * ? The symbol * tells the computer that you are declaring a pointer. Actually it depends on context. In a statement like int *ptr; the * tells that you are declaring a pointer. In a statement like int i = *ptr; it tells that you want to assign value pointed to by ptr to variable i.

The symbol * is also called as Indirection Operator/ Dereferencing Operator.


Why do we Use a Multidimensional Array? A multidimensional array can be useful to organize subgroups of data within an array. In addition to organizing data stored in elements of an array, a multidimensional array can store memory addresses of data in a pointer array and an array of pointers.

Multidimensional arrays are used to store information in a matrix form. e.g. a railway timetable, schedule cannot be stored as a single dimensional array. One can use a 3-D array for storing height, width and length of each room on each floor of a building.
How do you assign an address to an element of a pointer array ? We can assign a memory address to an element of a pointer array by using the address operator, which is the ampersand (&), in an assignment statement such as ptemployee[0] = &projects[2]; Run Time Memory Allocation is known as ? Allocating memory at runtime is called a dynamically allocating memory. In this, you dynamically allocate memory by using the new operator when declaring the array, for example : int grades[] = new int[10]; What method is used to place a value onto the top of a stack? push() method, Push is the direction that data is being added to the stack. push() member method places a value onto the top of a stack. What method removes the value from the top of a stack? The pop() member method removes the value from the top of a stack, which is then returned by the pop() member method to the statement that calls the pop() member method. What does isEmpty() member method determines? isEmpty() checks if the stack has at least one element. This method is called by Pop() before retrieving and returning the top element. What is a queue ? A Queue is a sequential organization of data. A queue is a first in first out type of data structure. An element is inserted at the last position and an element is always taken out from the first position. What is the relationship between a queue and its underlying array? Data stored in a queue is actually stored in an array. Two indexes, front and end will be used to identify the start and end of the queue.

When an element is removed front will be incremented by 1. In case it reaches past the last index available it will be reset to 0. Then it will be checked with end. If it is greater than end queue is empty. When an element is added end will be incremented by 1. In case it reaches past the last index available it will be reset to 0. After incrementing it will be checked with front. If they are equal queue is full.
Which process places data at the back of the queue? Enqueue is the process that places data at the back of the queue. Why is the isEmpty() member method called? The isEmpty() member method is called within the dequeue process to determine if there is an item in the queue to be removed i.e. isEmpty() is called to decide whether the queue has at least one element. This method is called by the dequeue() method before returning the front element. How is the front of the queue calculated ? The front of the queue is calculated by front = (front+1) % size. What does each entry in the Link List called? Each entry in a linked list is called a node. Think of a node as an entry that has three sub entries. One sub entry contains the data, which may be one attribute or many attributes. Another points to the previous node, and the last points to the next node. When you enter a new item on a linked list, you allocate the new node and then set the pointers to previous and next nodes. What is Linked List ? Linked List is one of the fundamental data structures. It consists of a sequence of? nodes, each containing arbitrary data fields and one or two (links) pointing to the next and/or previous nodes. A linked list is a self-referential datatype because it contains a pointer or link to another data of the same type. Linked lists permit insertion and removal of nodes at any point in the list in constant time, but do not allow random access. What member function places a new node at the end of the linked list? The appendNode() member function places a new node at the end of the linked list. The appendNode() requires an integer representing the current data of the node. How is any Data Structure application is classified among files? A linked list application can be organized into a header file, source file and main application file. The first file is the header file that contains the definition of the NODE structure and the LinkedList class definition. The second file is a source code file containing the implementation of member functions of the LinkedList class. The last file is the application file that contains code that creates and uses the LinkedList class. Which file contains the definition of member functions? Definitions of member functions for the Linked List class are contained in the LinkedList.cpp file. What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model.

1. RDBMS Array (i.e. Array of structures) 2. Network data model Graph 3. Hierarchical data model Trees.
Difference between calloc and malloc ? malloc: allocate n bytes calloc: allocate m times n bytes initialized to 0

Difference between DFS and BFS?


1. bfs uses queue implementation ie.FIFO dfs uses stack implementation ie. LIFO 2. dfs is faster than bfs 3. dfs requires less memory than bfs 4. dfs are used to perform recursive procedures.

C++ interview questions and answers


1. Explain Copy Constructor.
It is a constructore which initializes it's object member variable with another object of the same class. If you don't implement a copy constructor in your class, the compiler automatically does it.

2. When do you call copy constructors?


Copy constructors are called in these situations: i.)when compiler generates a temporary object ii.)when a function returns an object of that class by value iii.)when the object of that class is passed by value as an argument to a function iv.)when you construct an object based on another object of the same class

3. Name the implicit member functions of a class.


i.) default ctor ii.) copy ctor iii.) assignment operator iv.) default destructor v.) address operator

4. Explain storage qualifiers in C++.


i.) Const - This variable means that if the memory is initialised once, it should not be altered by a program. ii.) Volatile - This variable means that the value in the memory location can be altered even though nothing in the program code modifies the contents. iii.) Mutable - This variable means that a particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.

5. EXplain dangling pointer.


When the address of an object is used after its lifetime is over, dangling pointer comes into existence. Some examples of such situations are: Returning the addresses of the automatic variables from a function or using the address of the memory block after it is freed.

6. In what situations do you have to use initialization list rather than assignment in constructors.
When you want to use non-static const data members and reference data members you should use initialization list to initialize them.

7. When does a class need a virtual destructor?


If your class has at least one virtual function, you should have a virtual destructor. This allows you to delete a dynamic object through a baller to a base class object. In absence of this, the wrong destructor will be invoked during deletion of the dynamic object.

8. What is the type of this pointer? When does it get created?


It is a constant pointer type. It gets created when a non-static member function of a class is called.

9. How would you differentiate between a pre and post increment operators while overloading?
Mentioning the keyword int as the second parameter in the post increment form of the operator++() helps distinguish between the two forms.

10. What is a pdb file?


A program database (PDB) file contains debugging and project state information that allows incremental linking of a Debug configuration of the program. This file is created when you compile a C/C++ program with /ZI or /Zi or a Visual Basic/C#/JScript .NET program with /debug.

11. You run a shell on UNIX system. How would you tell which shell are you running?
To check this you can simply do the Echo $RANDOM. The results will be: - Undefined variable if you are from the C-Shell, - A return prompt if you are from the Bourne shell, - A 5 digit random number if you are from the Korn shell. You could also do a ps -l and look for the shell with the highest PID.

12.What are Stacks? Give an example where they are useful.


A Stack is a linear structure in which insertions and deletions are always made at one end i.e the top - this is termed as last in, first out (LIFO). Stacks are useful when we need to check some syntex errors like missing parentheses.

13. Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.
An external iterator is implemented as a separate class that can be "attach" to the object that has items to step through while an internal iterator is implemented with member functions of the class that has items to step through. With an external iterator many different iterators can be active simultaneously on the same object - this is its basic advantage.

14. Do you think the following code is fine? If not, what is the problem?
T *p = 0; delete p; No, the code has a problem. The program will crash in an attempt to delete a null pointer.

15. In a function declaration, what does extern mean?


The extern here tells the compiler about the existence of a variable or a function, even though the compiler hasnt yet seen it in the file currently being compiled. This variable or function may be defined in another file or further down in the current file.

16. You want to link a C++ program to C functions. How would you do it?
This can be done by using the extern "C" linkage specification around the C function declarations.

17. Exlpain STL.


STL stands for Standard Template Library. It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification.

18. What are the different types of STL containers?


Following are the 3 types of STL containers: 1. Adaptive containers - for e.g. queue, stack 2. Associative containers - for e.g. set, map 3. Sequence containers - for e.g. vector, deque

19. Explain Stack unwinding?


Stack unwinding is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught.

20. How would you find out if a linked-list is a cycle or not?


We can find out if the linked-list is not a cycle by using two pointers. One of them goes 2 nodes every time while the second one goes at 1 node each time. If there is a cycle, the one that goes 2 nodes each time will meet the one that goes slower. If this happens, you can say that the linked-list is a cycle else not.

You might also like