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

implement a function to sort list

The most efficient sorting algorithm in general, quicksort, is applicable to arrays because elements in arrays can be accessed in O(1) time based on indexes. It takes more time to locate a node in a list, so we have to utilize other algorithms to sort lists.
Let’s take a list with four nodes as an example to analyze the process of the insert sort algorithm (Figure 3-6(a)). A list is split into two parts. The first part contains nodes already sorted, and the second part is not sorted yet. The node pointed by P1 is the last sorted node, which is initialized to the first node, and the node pointed to by P2 is the next one to be sorted.
When node 1 is the next node to be sorted, there is only one node (node 2) in the sorted list. Because the value 1 is less than the value in the list head, node 1 becomes the new head of the sorted list, and node 2 is linked to the next node of the previous node 1, which is node 4 (Figure(b)). Node 2 is still the last node in the sorted list, so it does not move P1, and only moves P2 to the next node of node 2.
The next node to be sorted is node 4. It traverses from the head node in order to find an appropriate location in the sorted list. Since the value 4 is greater than the value 2 in the last node of the sorted list, it is not necessary to relink nodes. Node 4 becomes the new last node of the sorted list, so it is pointed to by P1 (Figure(c)).
Now the next node to be sorted is node 3. It traverses from the head node again in order to find an appropriate location in the sorted list. Node 3 is linked between node 2 and node 4. Node 4 is still the last node in the sorted list. Since there are no nodes left after node 4, the whole list is sorted (Figure(d)). 



The process to sort a list with four nodes. P1 points to the last node in the sorted list, and P2
points to the next node to be inserted into the sorted list, which always follows P1. (a) P1 is initialized to the first node, and P2 is initialized to the second one. (b) The node with value 2 is inserted into the sorted list. (c) The node with value 4 is inserted into the sorted list. (d) The node with value 3 is inserted into the sorted list.
The insert sort algorithm for lists can be implemented in C++, as shown in bellow

C++ Code to Sort a List
void Sort(ListNode** pHead) {
    if(pHead == NULL || *pHead == NULL)
return; 

    ListNode* pLastSorted = *pHead;
    ListNode* pToBeSorted = pLastSorted->m_pNext;
    while(pToBeSorted != NULL) {
        if(pToBeSorted->m_nValue < (*pHead)->m_nValue) {
            pLastSorted->m_pNext = pToBeSorted->m_pNext;
            pToBeSorted->m_pNext = *pHead;
            *pHead = pToBeSorted;
}
else {

            ListNode* pNode = *pHead;
            while(pNode != pLastSorted
                && pNode->m_pNext->m_nValue < pToBeSorted->m_nValue) {
                pNode = pNode->m_pNext;
            }
            if(pNode != pLastSorted) {
                pLastSorted->m_pNext = pToBeSorted->m_pNext;
                pToBeSorted->m_pNext = pNode->m_pNext;
                pNode->m_pNext = pToBeSorted;
} else
                pLastSorted = pLastSorted->m_pNext;
}
        pToBeSorted = pLastSorted->m_pNext;
    }
}
Because it has to scan O(n) nodes on the sorted list in order to find an appropriate location to insert a new node, it costs O(n2) time to sort a list with n nodes.
Test Cases:
  • Sort a list with multiple nodes, with/without duplicated values
  • The input list has only one node
  • The input head node of a list is NULL
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



Implementing a Class or Member Function in C++


Implementing a Class or Member Function in C++ 

The third type of C++ interview questions is based on implementing a class or some member functions. Usually it is more difficult to write code than to read and analyze sample code. Many C++ coding interview questions focus on constructor or destructor functions as well as overloading operators. For instance, the following problem about an assignment operator is such an example.
 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

8086 Interview Questions Faqs

8086 Interview Questions Faqs
1)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.
2)What are the various interrupts in 8086?
Maskable interrupts, Non-Maskable interrupts.
3)What is meant by Maskable interrupts?
An interrupt that can be turned off by the programmer is known as Maskable interrupt.
4)What is Non-Maskable interrupts?
An interrupt which can be never be turned off (ie.disabled) is known as Non-Maskable interrupt.
5)Which interrupts are generally used for critical events?
Non-Maskable interrupts are used in critical events. Such as Power failure, Emergency, Shut off etc.,
6)Give examples for Maskable interrupts?
RST 7.5, RST6.5, RST5.5 are Maskable interrupts
7)Give example for Non-Maskable interrupts?
Trap is known as Non-Maskable interrupts, which is used in emergency condition.
8)What is the Maximum clock frequency in 8086?
5 Mhz is the Maximum clock frequency in 8086.
9)What are the various segment registers in 8086?
Code, Data, Stack, Extra Segment registers in 8086.
10)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 retrived first.
11)What are the address lines for the software interrupts?
RST0 0000 H
RST1 0008 H
RST2 0010 H
RST3 0018 H
RST4 0020 H
RST5 0028 H
RST6 0030 H
RST7 0038 H
12)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.
13)Which is the tool used to connect the user and the computer? Interpreter is the tool used to connect the user and the tool.
14)What is the position of the Stack Pointer after the PUSH instruction? The address line is 02 less than the earlier value.
15)What is the position of the Stack Pointer after the POP instruction? The address line is 02 greater than the earlier value.
16)Logic calculations are done in which type of registers?Accumulator is the register in which Arithmetic and Logic calculations are done.
17)What are the different functional units in 8086?
Bus Interface Unit and Execution unit, are the two different functional units in 8086.
18)Give examples for Micro controller?
Z80, Intel MSC51 &96, Motorola are the best examples of Microcontroller.
19)What is meant by cross-compiler?
A program runs on one machine and executes on another is called as cross-compiler.
20)What are the address lines for the hardware interrupts?
RST 7.5 003C H
RST 6.5 0034 H
RST 5.5 002C H
TRAP 0024 H
20)Which Segment is used to store interrupt and subroutine return address registers?
Stack Segment in segment register is used to store interrupt and subroutine return address registers.
21)Which Flags can be set or reset by the programmer and also used to control the operation of the processor?
Trace Flag, Interrupt Flag, Direction Flag.
22)What does EU do?
Execution Unit receives program instruction codes and data from BIU, executes these instructions and store the result in general registers.
23)Which microprocessor accepts the program written for 8086 without any changes?
8088 is that processor.
24)What is the difference between 8086 and 8088?
The BIU in 8088 is 8-bit data bus & 16- bit in 8086.Instruction queue is 4 byte long in 8088and 6 byte in 8086.

Embeded Interview --8086 family interview questions

Embeded Interview --8086 family interview questions Microcontrollers and Embeded Systems
DESIN ENGINEER - Flytech Engineering - Chennai
Embedded Design Engineer - Autolite Enterprise -Rajkot
Faculty for Fashion Design - Liad institute of art & design - Ahmedabad
What is an interrupt?
What is ALE?
What are set up time & hold time constraints?
What is the difference between MOV and MVI?
How do you convert XOR to XNOR?
Why are program counter and stack pointer 16-bit registers?
What is PSW?
Explain RC circuit’s charging and discharging?
8085 is how many bit microprocessor?
What happens during DMA transfer?
What is flag, bus?
What is the immediate addressing mode?
What will you do if the delay of the combinational
Which type of architecture 8085 has?
What do you mean by wait state?
What are the different Adder circuits you studied?
How many memory locations can be addressed
What are the different addressing modes in 8085?
What is program counter use?
How do you detect if two 8-bit signals are same?
What is the function of accumulator?
What are the different flags in 8085?
Which line will be activated when an output device
How do you detect a sequence of "1101" arriving
Why is data bus bi-directional?
What are the functions of RIM, SIM, IN?
What is a program counter?
Explain the working of a binary counter?
What is the difference between 80286 and 80287?
What does it mean by embedded system?
Explain the functions of ALE in 8085.
Draw a Transmission Gate-based D-Latch?
What are tri-state devices and why they are
What is wait state need?