Cisco Systems Interview Question
Software Engineer / DevelopersDeletion of node -> assumption that in function we pass the index of the node which is required to be deleted
void DeleteNode(struct node** head, int index)
{
int count = 0;
struct node* current = *head;
struct node* prev = current;
if (index == 0)
{
//special case
*head = current->next;
free(current);
return;
}
while (current != NULL)
{
if (count == index)
{
struct node* save = current->next;
free(current);
prev->next = save;
}
prev = current;
current = current->next;
count++;
}
}
Macro for min of 2 is as follows:
#define min(x,y) (x)>(y)?(y):(x) //important are the braces
reverse string function is as follows:
void ReverseString(char str[], int start, int end)
{
char temp;
while(end>start)//end is the length of the string and start is the starting of the //string
{
temp = str[start];
str[start] = str [end];
str[end] = temp;
start++;
end--;
}
return;
}
Pre-emptive in Operating systems is act of temporarily interrupting the task being carried out by computing system, without its co-operation and with the intention of resuming the task later on. this is called Context switch.
e.g round robin scheduling in OS
OSI layer: Application, presentation, session, transport, network, data link and physical
#define MIN(x,y) = (x>y?y:x)
- AL June 15, 2011