Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Write a program for reversing each word in a string.

Answer»

We will make use of a stack for pushing all letters until a space is found in a given string. When space is encountered, we will empty the stack and the reversed word will be printed with a space at the end. This process will be continued until the end of the string has been reached.

// C++ program#include <bits/stdc++.h>using namespace std;// Reverses each word of a stringvoid reverseEachWords(string s){ stack<char> stk; /* TRAVERSES the given string and all the characters will be pushed to stack until a space is found. */ for (int i = 0; i < s.length(); ++i) { if (s[i] != ' ') stk.push(s[i]); else { // Contents of the stack will be printed when a space is found. while (stk.empty() == false) { cout << stk.top(); stk.pop(); } cout << " "; } } // As there may not be space after last word. while (stk.empty() == false) { cout << stk.top(); stk.pop(); }}int main(){ string s = "Welcome To InterviewBit"; reverseWords(s); return 0;}

OUTPUT:

emocleW oT tiBweivretnIConclusion:

The Cisco INTERVIEW questions and answers provided here will guide you to prepare for your upcoming interview and face the questions confidently. In order to add more weightage to your resume, you can take up a Cisco certification or course.

Alternatively, you may go through resources on various other Networking and Hardware concepts to grow your knowledge. PREPARING for the Cisco interview questions and answers in this article will definitely help you stand out as a strong potential candidate for the job.

Useful Resources:

  • Networking Interview
  • Operating System Interview
  • Data Structure Interview
  • Algorithm Interview
2.

Write a program for finding the first and last occurrences (or positions) of a number in an array of a sorted manner.

Answer»

Assign firstPos and lastPos values as -1 in the beginning, as we need to find them yet. Within for loop, you need to compare a given element with each element of an ARRAY. When an element is found for the first time, we will update the firstPos value with i. After that, WHENEVER we find an element, we will update the lastPos value with i. Then firstpos and lastPos value will be printed.

// C++ PROGRAM#include <bits/stdc++.h>using namespace std;void findFirstAndLastFunc(int a[], int n, int x){ int firstPos = -1, lastPos = -1; for (int i = 0; i < n; i++) { if (x != a[i]) continue; if (firstPos == -1) firstPos = i; lastPos = i; } if (firstPos != -1) COUT << "First Occurrence = " << firstPos<< "\n Last Occurrence = " << lastPos; else cout << "Element not Found";}int main(){ int a[] = { 1, 2, 2, 2, 3, 3, 4, 5, 7, 7}; int n = sizeof(a) / sizeof(int); int x = 7; findFirstAndLastFunc(a, n, x); return 0;}

Output:

First Occurrence = 8Last Occurrence = 9
3.

Write a program for finding the greatest difference between two elements of an array that is in increasing order of elements.

Answer»

A SOLUTION for this problem can be achieved with the usage of two loops. Initially, we consider the maximum difference value as the difference between the first two array elements. Later, the elements will be picked one by one in the outer loop and the difference between the picked element and every other array element will be calculated in the inner loop, then that difference will be compared with the maximum difference calculated so far.

Program:

// Java programclass MaxDiffrence{ /* The function will ASSUME that there will be at least two elements in an array. The function will return a negative value if the array is in decreasing order of sorting. This function will return 0 if elements are equal. */ int maximumDiff(int x[], int size) { int res = x[1] - x[0]; int i, j; for (i = 0; i < size; i++) { for (j = i + 1; j < size; j++) { if (x[j] - x[i] &GT; res) res = x[j] - x[i]; } } return res; } // Driver program for testing above function public static void main(String[] args) { MaxDifference md = new MaxDifference(); int array[] = {2, 3, 90, 10, 120}; System.out.println("Maximum difference between two elements of an array is " + md.maximumDiff(array, 5)); }}

Output:

Maximum difference between two elements of an array is 118
4.

Write a program for printing all permutations of a given string.

Answer»

A permutation means re-arranging the ordered list(L) elements into a correspondence of one-to-one with the L itself. It is also known as an “order” or “arrangement NUMBER”. There will be N! permutation for a string with length n.

For finding all permutations of a given string, the recursive algorithm will make use of backtracking which finds the permutation of numbers by swapping a single element per iteration.

We are providing the “XYZ” string as an input in the below given example. It will produce 6 permutations for a given string. The permutation for a string “XYZ” are “XYZ”, “YXZ”, “ZYX”, “XZY”, “YZX”, “ZXY”.

PROGRAM:

// C Program to print all permutations of a given string including duplicates#include <stdio.h>#include <string.h>// Function for swapping values at two pointers void swap(char *a, char *b) { char temp; temp = *a; *a = *b; *b = temp;}/* Function for printing permutations of a string. This function takesthree parameters: String, Starting index of the string, LAST index ofthe string. */void permute(char *a, int beg, int end){ int i; if (beg == end) printf("%s\n", a); else { for (i = beg; i <= end; i++) { swap((a+beg), (a+i)); permute(a, beg+1, end); //backtracking method swap((a+beg), (a+i)); } }}// Driver program for testing above defined functions int MAIN(){ char string[] = "XYZ"; int n = strlen(string); permute(string, 0, n-1); return 0;}

Output:

XYZXZYYXZYZXZYXZXY
5.

Write a program to create a stack using a linked list in Java.

Answer»

We can easily implement a stack using the LINKED list. A stack will have a top pointer which is the “head” of the stack where the item will be pushed and popped at the head of the list. The link field of the first node will be null and the link field of the second field will have the address of the first node and so on and the address of the last node will be stored in the “top” pointer.

The major advantage of linked list usage over an array is we can implement a stack that can grow or shrink according to the need. As the array is of fixed size, it will lead to stack overflow by putting restrictions on the maximum capacity of an array. In the linked list, each new node will be allocated dynamically, so overflow will not occur.

Stack Operations are:

  • PUSH() : This function will INSERT an element into the linked list which in turn will be added to the top node of Stack.
  • pop() : This function will return the top element from the Stack and the top pointer will be moved to the second node of Stack.
  • peek(): This function will return the topmost element in the stack.
  • display(): This function will print all the elements of Stack.
  • isEmpty(): It will return true if the Stack is empty otherwise it returns false.
// Java program// Importing packageimport static java.lang.System.exit; // Creating Stack using Linked listclass StackLinkedlist { // A node of linked list private class Node { // INTEGER DATA int info; // Reference variable of Node type Node link; } // Creating a global top reference variable Node top; // Constructor StackLinkedlist() { this.top = null; } // Function for adding an element i in the stack public void push(int i) // Insert at the beginning { // Creating a new node t and allocate memory Node t = new Node(); /* Checking if the stack is full, then inserting an element would lead to stack overflow*/ if (t == null) { System.out.print("\nStack Overflow"); return; } // Initializing data into info field of t node t.info = i; // Add top reference into link field of t node t.link = top; // Update top reference top = t; } // Function for checking if the stack is empty or not public boolean isEmpty() { return top == null; } // Function for returning topmost element of a stack public int peek() { // Checking for empty stack if (!isEmpty()) { return top.info; } else { System.out.println("Stack is empty"); return -1; } } // Function to pop the topmost element from the stack public void pop() { // Checking for stack underflow if (top == null) { System.out.print("\nStack Underflow"); return; } // Updating the top pointer to point to the next node top = (top).link; } public void show() { // Checking for stack underflow if (top == null) { System.out.printf("\nStack Underflow"); exit(1); } else { Node tmp = top; while (tmp != null) { // Printing node data System.out.printf("%d->", tmp.info); // Assigning tmp link to tmp node tmp = tmp.link; } } }}//Class with main() functionpublic class ImplementStack { public static void main(String[] args) { // Creating object for the StackLinkedList class StackLinkedlist ob = new StackLinkedlist(); // Inserting values for stack ob.push(15); ob.push(20); ob.push(25); ob.push(30); // Printing elements of Stack ob.display(); // Printing Top element of Stack System.out.printf("\nTop element of Stack is %d\n", ob.peek()); // Deleting top element of the Stack ob.pop(); ob.pop(); // Printing Stack elements ob.show(); // Printing Top element of Stack System.out.printf("\nTop element of Stack is %d\n", ob.peek()); }}

Output:

30->25->20->15->Top element of Stack is 3020->15->Top element of Stack is 20
6.

What is an auto keyword in C?

Answer»
  • The auto keyword is used for declaring a variable that has a complicated type. For example, an auto keyword can be used for variable declaration where the initialization expression CONSISTS of templates, pointers to members, or pointers to functions.
  • It can also be used for declaring and initializing a variable to a lambda expression. You cannot DECLARE the variable type on your own because the type of lambda expression will be only known to the compiler.
  • Auto variables can be accessed only within the block or function in which they have been declared and cannot be accessed OUTSIDE of them. By default, they are assigned with garbage value whenever they are declared without assigning any value.

Syntax: auto <data_type&GT; <variable_name>;

Example:

auto int x = 1;

Here, x is a variable of storage class “auto” and with DATA type int.

7.

How Multithreading will be achieved in Python?

Answer»
  • Python has a Global Interpreter Lock (GIL) that makes sure only one of your ‘threads’ can be executed at a time. A thread will acquire the GIL, does a small amount of work, then the GIL will be passed onto the next thread.
  • This happens so QUICKLY as if your threads are executing in parallel, but in reality, they are just taking turns using the same CPU core.
  • All this GIL PASSING process will add overhead to the execution. This indicates that, if you want to speed up your code run, then the usage of the threading package often is not considered to be a GOOD idea.
8.

What is a void pointer in C? Can a void pointer be dereferenced without being aware of its type?

Answer»

A VOID POINTER is a pointer that is useful in POINTING to the memory location having an undefined data type at the time of defining a variable, which means it can be any data of any arbitrary type. You can dereference a void pointer only after explicit casting. For example:

INT x = 10;void *y = &x;printf(“%d\n”, *((int*)y));

In the above-given CODE, we have declared a normal variable x with the integer data type, and assigned reference of x into a void pointer y. Using printf(), we are displaying the value of y by dereferencing it.

9.

Differentiate between C and C++.

Answer»
CC++
It is procedural programming in which code will be in the form of a set of procedures for developing the applications.It is a hybrid programming language as it supports both procedural and object-oriented programming concepts.
It does not support oops features like encapsulation, polymorphism, and inheritance.It supports oops features like encapsulation, polymorphism, and inheritance.
It does not support data HIDING.It supports data hiding through encapsulation.
Operator and function overloading is not supported.Operator and function overloading is supported.
Don’t have access SPECIFIERS. Does have access specifiers.
Data and functions will be kept separated and will not be encapsulated together.Data and functions will be encapsulated together as an object.
It FOCUSES on method or process, instead of focusing on data.It focuses on data, instead of focusing on method or procedure.
Virtual and FRIEND functions are not supportedVirtual and friend functions are supported.
It does not support exception handling.It supports exception handling.
Namespace feature is not provided. Namespace feature is allowed to avoid name COLLISIONS.
10.

How will swapping lead to better memory management?

Answer»

Swapping is a process/memory management TECHNIQUE used by the operating system(os) for increasing the processor utilization by moving a few blocked processes from the MAIN memory into the secondary memory. This will lead to a QUEUE formation that has temporarily suspended processes and the execution will be continued with the processes that are NEWLY arrived. At the regular intervals fixed by the operating system, processes can be moved from the main memory to secondary storage, and then later they can be moved back. Swapping will ALLOW multiple processes to run, that can fit into memory at a single time. Thus, we can say that swapping will lead to better memory management.

11.

What is Virtual memory?

Answer»
  • Virtual Memory is a method of storage allocation where a part of secondary memory will be emulated as it is the main memory of a COMPUTER. The virtual memory will SOLVE the insufficient memory problem by converting part of disk memory into virtual addresses, thus will create a large size of RAM for accomodating the increased memory requirement demand and will provide the illusion that we have a lot of memory. MODERN MICROPROCESSORS will have a built-in Memory Management Unit(MMU) which will translate the virtual addresses into physical addresses.
  • The size of virtual storage is limited by the computer SYSTEM’s addressing scheme and the available quantity of secondary memory will not depend on an actual number of the main storage locations.
  • In common, Virtual memory will be implemented through demand paging or in a segmentation system. Also, demand segmentation can be used for providing virtual memory.
12.

What is a deadlock in Operating Systems? What are the situations for the deadlock to happen?

Answer»

DEADLOCK REFERS to the situation that happens in the operating system where each process will enter into the waiting state for obtaining the resource which has been ASSIGNED to some other process.

Consider a real-time example of traffic that is going only in a single direction. Here, we can consider the bridge as a resource. If one car backs up, the deadlock situation will be RESOLVED easily. Multiple cars may have to be backed up on deadlock OCCURRENCE. So it might lead to starvation.

The process will be considered to be in a deadlock when the following conditions get satisfied simultaneously:

  • Mutual Exclusion: When more than one process shares the same resource and all the processes are different, then each process of them has to wait for the other for utilizing the resource as at a time only one process can use the resource.
  • Hold and Wait: A process is already holding the resource(at least one) and waiting for resources.
  • No pre-emption: We cannot forcefully stop or remove a process among the waiting processes, for releasing the resource.
  • Circular Wait: A group of processes will be waiting in a circular manner for the resources held by each other.
13.

What are the different types of memories used in the CISCO router?

Answer»

Different types of memories are being used in a CISCO router. They are:

  • Random Access Memory (RAM): RAM used in a router is the same as the RAM that is installed in our Mobile Phones, Laptops, and PCs. The RAM will be divided into two AREAS:
    • Main Processor Memory: It stores the information that belongs to the routing table, running router configuration, and ARP (Address Resolution Protocol) cache.
    • Shared I/ry: It is a temporary storage memory where the queued data packets will be stored.
      When the router gets restarted or rebooted, all the information stored within the RAM will be deleted(that is why it is considered as Volatile memory). We can store the data permanently using NVRAM.
  • Non-Volatile Random Access Memory (NVRAM): NVRAM is useful in STORING the start-up configuration FILE which are copies of the CISCO Router Configuration file and will be retained even after rebooting or restarting of router OCCURS. In this, the data will not be lost and can be easily recovered by rebooting or switching off the router. If you want to permanently save the running configuration files, these files should be moved from RAM to NVRAM.
  • Read-Only Memory (ROM): The boot procedure of a CISCO router will begin from the ROM memory section. ROM will have programming instructions such as Bootstrap program and POST (Power-On-Self-Test). POST test is useful in verifying whether hardware components like RAM, CPU, and interfaces are properly working or not. If they are not functioning properly, an error message will be sent by POST. After this, for setting up the CPU and boot functions of the router, the bootstrap application is used. The bootstrap program will be in charge of finding and loading the operating SYSTEM (IOS) of the router. All this information will be saved or stored inside the ROM and the data will be retained even after switching off or rebooting the router.
  • Flash Memory: It is an EPROM (Erasable Programmable Read-only Memory) chip that is more cost-effective for enterprise environments. The router operating system i.e., IOS (Internetwork Operating System) will be available in flash memory. It can be easily upgradable and does not need any hardware changes. Also, the content in flash memory will be retained when the router is switched off or rebooted.
14.

Explain how Cut-through LAN switching works.

Answer»

Cut-through LAN switching is useful in packet-switching systems. In the packet-switching technique, the message will be divided into many SMALLER UNITS known as packets and it will be individually routed from source to the destination. It does not require the establishment of a dedicated circuit for communication, as it is a connection-less network switching technique.

In cut−through switching, when a packet or data frame begins arriving at a switch or bridge, the transmission of data can be started immediately after the destination address field has arrived. The switch will do a look–up at the address table stored in it and check for the VALIDITY of the destination address. If it is a valid address and the outgoing link is available, the data frame transmission into the destination port will be immediately started by a switching device, even before the ARRIVAL of the remaining frame.

Here, the switching device will act as a forwarder of data frames. The error checks cannot be performed when it STARTS forwarding, as the total frame is still not available. For error handling, it depends upon the destination devices.

15.

What is a transparent firewall?

Answer»

A transparent firewall or bridge firewall will behave like a line of the layer among 2 devices and can be easily installed into an existing NETWORK without any modification into the Internet Protocol (IP) address. The transparent firewall will allow for entering into the traffic of layer 3 from the level of HIGHER security to lower security LEVELS without the help of access lists. It will act SIMILAR to a bridge as it inspects and moves network frames between interfaces.

A transparent firewall is considered a “stealth firewall” that supports outside as well as inside interfaces. Using this, security equipment can be connected with the same network on external and internal ports, with a separate VLAN(Virtual Local Area Network) for each interface.

16.

What is the CISCO default TCP session timeout?

Answer»

The default timeout in the TCP session for CISCO will be ONE minute. Here, connection slots will GET freed on an average of SIXTY seconds later, when the sequence of normal connection close has been COMPLETED. It can be configured into other settings as per the requirements.

For the connection and translation slots of different protocols, a global IDLE timeout duration can be set manually. The resources will be returned so that pools can be freed, in case slots are not used for the specified idle time.

17.

How is a TCP connection made?

Answer»

A TCP(Transmission Control Protocol) connection will be done as given below:

  • Step 1: At first, the receiver (HOST) will send a packet to the sender (SERVER) with an SYN (SYNchronize) flag. It is considered as an attempt made to open a connection. Then, the server will respond with an SYN flag and ACK (ACKnowledge) flag for acknowledging(approving) the connection. Now, the receiver will send an ACK flag for confirming the handshake. The operating systems at both ends will be kept informed about the connection establishment.
  • Step 2: Now the sender will begin data transmission. It will ALSO gain acknowledgements from the receiver. A timer will begin when the sender initiates the sending of data.
  • Step 3: The data will be retransmitted by the sender if it hasn’t received any acknowledgements even after the timer limit has been exceeded.
  • Step 4: When the receiver buffer is full (in the case of windowing), the receiver will send a stop signal to the sender. The sender will stop the data transmission.
  • Step 5: Then after all the data processing is done, the receiver will be sending a go signal into the sender. Now, the sender will again begin transmitting the data.
18.

What are the Benefits of Subnetting?

Answer»

Subnetting refers to the process of dividing a larger network into smaller networks. In the below-given image, the network has been divided into two broadcast networks, which will reduce the network load and will provide greater network security to the users.

The benefits of subnetting are:

  • Improvement in network performance and speed: Subnetting will enable you to make sure about information remains in the broadcast domain or subnetted network, which permits other subnets for maximizing their speed and effectiveness. Also, subnetting will divide broadcast domains of your network which enables you to control the traffic flow in a better way, thus increasing network performance.
  • Reduction in network congestion: Using a router for MOVING the traffic between subnets will lead to no broadcast traffic and any information that does not REQUIRE to be routed will be moved to other subnets. As the traffic within each subnet has been reduced, there is an increase in the speed of each subnet, which in turn will ease the network congestion.
  • Boosting network security: You will be ABLE to control the flow of traffic with the help of ACLs (ACCESS Control Lists), QoS (Quality of Service), or route maps, ENABLING you for identifying threats, close entry points, and target your responses more easily.
  • Ease administration: Using subnetting, you will be able to create networks that have more logical host limits, as opposed to the IP addressing class limitations: 8 bits (Class A), 16 bits (Class B), and 24 bits (Class C). Subnetting will enable you for selecting the number of bits in your subnetwork, thus creating more realistic host limits. Subnetting will be an effective approach for keeping eyes on the systems of your network, which will help you for determining which system needs attention when problems arise. So we can say that subnetted networks are easier to manage and troubleshoot.
19.

What are TACACS (Terminal Access Controller Access Control System) and RADIUS (Remote Authentication Dial In User Service) in networking?

Answer»
  • TACACS: It is a group of remote AUTHENTICATION protocols useful in controlling remote authentication and other related services for the networked access control via a centralized server. TACACS will HELP for determining whether the user is having access to the network or not as it will permit the remote access server to communicate with an authentication server.
  • RADIUS: It is an AAA (Authentication, Authorization, and ACCOUNTING) protocol to control access to network resources. RADIUS is used by ISPs (Internet Service Providers) and corporations to manage access into the Internet or internal networks across a group of access technologies that INCLUDE wireless, DSL, modem, and VPNs.
20.

Give the reasons why a Layered model is used by the Networking industry.

Answer»
  • It PROVIDES systematic troubleshooting in the network.
  • It clarifies what task has to be done by general FUNCTION rather than how to do those tasks.
  • Modifications made to one LAYER doesn't affect the other layers in the LAYERED model.
21.

What is an IP access list?

Answer»

An IP access list is a rule set for traffic control in the network and for reducing the possibilities of network attacks. This list will be useful in filtering the traffic BASED on rules that are defined for incoming as well as outgoing networks. The standard IP access list features are:

  • PROVIDE bandwidth control: IP Access lists on a slower link are helpful in preventing excess traffic on a network.
  • Trigger dial-on-demand: Access lists do have the right to enforce the criteria for dial and disconnect.
  • Provide NAT control: Access lists are helpful in controlling which addresses are translated by NAT (Network Address Translation).
  • Control access to Virtual teletype (VTY): Access lists on an inbound vty are capable of controlling which person can access the lines to a device. Access lists on an outbound vty are capable of controlling the destinations to which can be reached by the lines from a device.
  • Authenticate remote shell (rsh) and Rate Control Protocol (RCP): Using access lists, it is possible to simplify the remote hosts, remote users, and local users identification in an authentication database that is configured for controlling the device access. For receiving incoming rsh as well as rcp protocol REQUESTS, the authentication database will enable the Cisco software.
  • Block UNWANTED traffic: These access lists are capable of filtering incoming/outgoing packets on an interface, thus helpful in controlling the network access depending on the source address, destination address, or user authentication. It is also useful in determining the traffic type that is forwarded or blocked at the device interface.
  • Limit debug command output: We can limit the debug output using access lists, depending on an IP address or a protocol.
22.

Explain in detail about Bridges in Networking and mention its usage.

Answer»

A BRIDGE is a networking device that will connect numerous LANs (Local Area Networks) for forming a larger LAN. Also, it can connect LAN segments to form newer LAN segments. It operates in the OSI MODEL’s Data-Link layer. Bridges are helpful in increasing the network capacity of a single LAN by joining multiple LANs.

Working of Bridge:

The bridge will connect two or more different LANs that are having similar protocols and help to communicate between the devices (nodes) in them. It will accept all the data packets and all of them will be amplified to the other side. The bridges are considered to be intelligent devices as they will permit the passing of only selective packets from them.

A bridge will pass only those packets which are addressed from the node of one network to the node of the other network. That means the bridge will consult a database on receiving the data frame for DECIDING whether to pass, transmit or discard the frame.

  • If the frame consists of a destination MAC (Media Access Control) address within the same network, then the bridge will pass the frame to that node and discard it later.
  • If the frame consists of a destination MAC address within the connected network, then the bridge will forward the frame towards it.

Uses of Bridge:

  • The capacity of the network will be INCREASED and multiplied as multiple smaller networks are combined to form a single network using the bridge.
  • The database in the bridge will help for deciding whether a data frame should be transmitted or discarded on receiving the data frame.
  • A single FAULTY node will be prevented from bringing down the whole network, by deciding on whether to forward or discard the data frame.
  • It helps for frame broadcasting to each node even if the MAC or destination address is not available.
  • With the help of a wireless bridge, we can connect the wireless networks with wireless segments.
23.

Which protocol will be used for booting diskless workstations?

Answer»

BootP or BOOTSTRAP Protocol will be used for booting the diskless workstations across the INTERNET by themselves. Similar to DHCP (DYNAMIC Host CONFIGURATION Protocol), BootP will allow a computer to obtain the server’s IP ADDRESS as well as their own IP address.

24.

What is a diskless workstation?

Answer»

Diskless workstations refer to the client computers that are in connection with a networked server. These computers will need only a minimum AMOUNT of hardware for interacting with the system by the user. They do not have a hard disk. Data and programs will be retrieved from the NETWORK. The server will do all the “hard work”, including data storage, booting, and performing calculations.

Diskless workstations are helpful in reducing the overall LAN cost as a single disk drive with large-capacity will be less expensive than multiple low-capacity drives. Along with this, it also simplifies the security and backups because all files are in a single place, i.e., on the file server. Also, data access from a larger REMOTE file server is usually faster than data access from a smaller local storage device. The major disadvantage of these diskless workstations is that they become useless on network FAILURE.