This problem isn't too hard You just need to start at the head of the list, and iterate to the end At each node, swap the values of pNext and pPrev Finally, set pHead to the last node in the list Node * pCurrent = pHead, *pTemp; while (pCurrent) { pTemp = pCurrent->pNext; pCurrent->pNext = pCurrent->pPrev; pCurrent->pPrev = temp; pHead = pCurrent; pCurrent = temp; }
Technology problems
Search Results
1. Write an algorithm to separate all ones & zeroes in an array.
Correct Answer: 1 Have two indexes pointing to two ends of array, say i and j 2 Approach towards each other with a check condition that they dont cross each other 3 Each iteration of while loop, swap the numbers pointed by two indexes when num[i] index number is not equal to 1 void sort() { int a[]={1,0,0,0,1,1,0,1,0,1,0,0,1,0}; int i=0; int j=13; int temp; while(j>i) { if(a[i]==1) i++; if(a[j]==0) j--; if(a[i]==0) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } for(i=0;i<14;i++) ConsoleWrite(a[i]+", "); } Output: 1,1,1,1,1,1,0,0,0,0,0,0,0
2. Define stored procedure. What are its advantages and disadvantages?
Correct Answer: A stored procedure is a segment of declarative SQL statements stored inside the database catalog A stored procedure can be invoked by triggers, other stored procedures or applications such as Java, C#, PHP, etc Advantages - Typically stored procedures help increase the performance of the applications Once created, stored procedures are compiled and stored in the database However MySQL implements the stored procedures slightly different MySQL stored procedures are compiled on demand After compiling a stored procedure, MySQL puts it to a cache And MySQL maintains its own stored procedure cache for every single connection If an application uses a stored procedure multiple times in a single connection, the compiled version is used, otherwise the stored procedure works like a query - Stored procedures helps reduce the traffic between application and database server because instead of sending multiple lengthy SQL statements, the application has to send only name and parameters of the stored procedure - Stored procedures are reusable and transparent to any applications Stored procedures expose the database interface to all applications so that developers don?t have to develop functions that are already supported in stored procedures - Stored procedures are secure Database administrator can grant appropriate permissions to applications that access stored procedures in the database without giving any permission on the underlying database tables Disadvantages - If you use a lot of stored procedures, the memory usage of every connection that is using those stored procedures will increase substantially In addition, if you overuse a large number of logical operations inside store procedures, the CPU usage will also increase because database server is not well-designed for logical operations - A constructs of stored procedures make it more difficult to develop stored procedures that have complicated business logic - It is difficult to debug stored procedures Only few database management systems allow you to debug stored procedures Unfortunately, MySQL does not provide facilities for debugging stored procedures -It is not easy to develop and maintain stored procedures Developing and maintaining stored procedures are often required specialized skill set that not all application developers possess This may lead to problems in both application development and maintenance phases
Correct Answer: The main types of system calls are as follows: Process Control: These types of system calls are used to control the processes Some examples are end, abort, load, execute, create process, terminate process etc File Management: These types of system calls are used to manage files Some examples are Create file, delete file, open, close, read, write etc Device Management: These types of system calls are used to manage devices Some examples are Request device, release device, read, write, get device attributes etc Information Maintenance: These types of system calls are used to set system data and get process information Some examples are time, OS parameters, id, time used etc Communications: These types of system calls are used to establish a connection Some examples are send message, received messages, terminate etc
Correct Answer: UDP (User Datagram Protocol) is a communications protocol that offers a limited amount of service when messages are exchanged between computers in a network that uses the Internet Protocol (IP)
5. Explain the basic difference between 32-bit and 64-bit operating system?
Correct Answer: A 32 bit processor is faster than a 64 bit processor, 64 bit processors are very commonly used that you can find it easily in any home pc but the main difference is the hardware you are having on your machine For 32 bits there isn't any need of any wide main bus to carry 32 bits at a time but for 64 bits its must that you should have a wider bus to carry 64bits
6. Write a method to fill all the spaces in a string with '%20'
Correct Answer: A system call is a functionsubroutine which interrupts the currently executing program and transfers control to the interrupt routineThe contents of the executing program are saved and after the interrupt routine finishes its function,control is transferred back to the executing program If we talk in the context of Linux then System calls are called kernel mode Whereas API (Application Programming Interface) is a function or a set of functions, objects, protocols or data-structures for the support of application development for developers/programmers It is actually a kind of function definition which specifies how to make available of a specific service of the system/OS to the other program/process or system Read more at: https://wwwqueryhomecom/48442/os-what-is-difference-between-system-call-and-api
Correct Answer: Marshalling is the process of gathering data from one or more applications or non-contiguous sources in computer storage, putting the data pieces into a message buffer, and organizing or converting the data into a format that is prescribed for a particular receiver or programming interface