TCS Placement: Sample Questions 341 - 342 of 502

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 341

Write in Short Short Answer▾

How to check whether a linked list is circular?

Edit

Explanation

  • Create two pointers, and set both 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” ) ;} }
  • If a list is circular, at some point pointer2 will wrap around and be either at the item just before pointer1, or the item before that. Either way, it՚s either 1 or 2 jumps until they meet.

Question 342

Describe in Detail Essay▾

What are the responsibilities of Data Link Layer?

Edit

Explanation

The Data Link Layer transforms the physical layer, a raw transmission facility, to a reliable link and is responsible for node-node delivery. It provides following functions:

  • Framing
    • Frames are streams of bits received from the network layer broken into manageable data units.
    • This division of stream of bits is done by Data Link Layer.
  • Physical Addressing

    The Data Link layer adds a header to the frame that defines physical address of the sender or receiver of the frame, if the frames are to be distributed to different systems on the network.

  • Flow Control
    • Provides a flow control mechanism to avoid a fast transmitter from running a slow receiver by buffering the extra bit.
    • Prevents overflow at the receiver side.
  • Error Control
    • Adds a trailer at the end of the frame for error control.
    • Also, duplication of frames is prevented by using this mechanism.
  • Access Control

    Protocols of this layer determine the devices that can control the link at any given time- when two or more devices are connected to the same link.