InternDoor

Marvell Technology interview prep

10 practice questions on the topics candidates reported from Marvell Technology interviews, with answers. The questions are ours; each one links to the interview report that names its topic.

Practise them as a timed round6 roles open at Marvell Technology

DSA 2

  1. DSAMedium

    For a positive integer n, what does (n & (n - 1)) == 0 tell you?

    1. n is even
    2. n is odd
    3. n has exactly two set bits
    4. n is a power of two
    Show the answer

    D. n is a power of two

    n - 1 flips the lowest set bit of n and every bit below it, so n & (n - 1) clears the lowest set bit. The result is zero only when n had exactly one set bit: 1, 2, 4, 8 and so on.

    This topic is named in a candidate’s interview report: Software firmware intern on-campus interview, on GeeksforGeeks.

  2. DSAMedium

    How do you print every root-to-leaf path of a binary tree?

    1. A level-order traversal printing each level
    2. A DFS that adds each node to a current path, prints the path at a leaf, and removes the node again when it returns
    3. Sort the nodes and print them
    4. An inorder traversal printed in one line
    Show the answer

    B. A DFS that adds each node to a current path, prints the path at a leaf, and removes the node again when it returns

    The path list is the recursion's backtracking state: push on entry, pop on exit. A tree of n nodes and height h has at most about n/2 leaves, so printing every path costs O(n * h).

    This topic is named in a candidate’s interview report: Software firmware intern on-campus interview, on GeeksforGeeks.

C and C++ 2

  1. C and C++Medium

    What does this print?

    unsigned n = 44;
    int count = 0;
    while (n) {
        n &= n - 1;
        count++;
    }
    printf("%d", count);
    1. 6
    2. 4
    3. 2
    4. 3
    Show the answer

    D. 3

    n & (n - 1) clears the lowest set bit, so the loop runs once per 1 bit. 44 is 101100 in binary: three 1s. This is Kernighan's method: it takes as many steps as there are set bits, not as many as there are bits.

    This topic is named in a candidate’s interview report: Intern on-campus interview, 2024, on GeeksforGeeks.

  2. C and C++Medium

    What does this print?

    int a[] = {5, 10, 15, 20};
    int *p = a + 1;
    printf("%d %d %d", *p + 1, *(p + 1), p[2]);
    1. 11 15 20
    2. 15 15 20
    3. 6 15 20
    4. 11 10 15
    Show the answer

    A. 11 15 20

    p points at a[1], which is 10. *p + 1 adds to the value: 11. *(p + 1) moves the pointer one int forward: a[2], 15. p[2] means *(p + 2): a[3], 20. Pointer arithmetic counts in elements, not bytes.

    This topic is named in a candidate’s interview report: Intern on-campus interview, 2024, on GeeksforGeeks.

Computer networks 6

  1. Computer networksMedium

    What is the TTL field in an IP packet for?

    1. Each router lowers it by one and drops the packet at zero, so packets cannot loop forever
    2. It sets how long a website may cache the page
    3. It is the packet's timestamp
    4. It sets the TCP retransmission timeout
    Show the answer

    A. Each router lowers it by one and drops the packet at zero, so packets cannot loop forever

    Time to live is a hop count. A routing loop would otherwise circulate a packet indefinitely. traceroute uses it: it sends packets with TTL 1, 2, 3 and records which router reports each one expired.

    This topic is named in a candidate’s interview report: Intern on-campus interview, 2024, on GeeksforGeeks.

  2. Computer networksMedium

    How does an Ethernet switch learn which of its ports leads to which device?

    1. It reads the source MAC address of each frame that comes in and records it against that port; a frame for an address it has not learnt yet is flooded out of every other port
    2. It asks the DHCP server
    3. It reads the IP address in each packet
    4. An administrator types in every address
    Show the answer

    A. It reads the source MAC address of each frame that comes in and records it against that port; a frame for an address it has not learnt yet is flooded out of every other port

    The table fills itself as devices talk, and entries expire after a few minutes so a moved device is relearnt. This is layer-2 work on MAC addresses; routers forward between networks at layer 3 by IP address.

    This topic is named in a candidate’s interview report: Intern on-campus interview, 2024, on GeeksforGeeks.

  3. Computer networksHard

    A 4,000-byte IPv4 datagram (a 20-byte header with no options) must cross a link whose MTU is 1,500 bytes. How many fragments are sent, and what is the fragment offset field of the last one?

    1. 3 fragments; last offset 2,960
    2. 2 fragments; last offset 185
    3. 3 fragments; last offset 370
    4. 4 fragments; last offset 555
    Show the answer

    C. 3 fragments; last offset 370

    The 3,980 data bytes go out in pieces of at most 1,480 (1,500 minus the header, a multiple of 8): 1,480, 1,480 and 1,020, so 3 fragments. The offset field counts 8-byte units, so the last one starts at byte 2,960, written as 370. Every fragment but the last has the more-fragments flag set.

    This topic is named in a candidate’s interview report: Intern on-campus interview, 2024, on GeeksforGeeks.

  4. Computer networksMedium

    How does traceroute find the routers along the path to a host?

    1. It asks each router for its routing table
    2. It looks each router up in DNS
    3. It sends probes with TTL 1, 2, 3 and so on; the router where a probe's TTL runs out drops it and sends back an ICMP Time Exceeded message, which reveals that router's address
    4. It reads the MAC address of every hop
    Show the answer

    C. It sends probes with TTL 1, 2, 3 and so on; the router where a probe's TTL runs out drops it and sends back an ICMP Time Exceeded message, which reveals that router's address

    Each router lowers the TTL by one, so a probe with TTL n dies at the n-th hop. Linux traceroute sends UDP probes by default and Windows tracert sends ICMP echo requests. A hop shown as * did not answer, often because of a firewall.

    This topic is named in a candidate’s interview report: Intern on-campus interview, 2024, on GeeksforGeeks.

  5. Computer networksEasy

    How does a MAC address differ from an IP address?

    1. A MAC address identifies a network interface on the local link (48 bits, set by the maker); an IP address identifies a host across networks and changes as the host moves between networks
    2. They are two names for the same number
    3. MAC addresses are used across the internet and IP addresses only inside a LAN
    4. In IPv4, IP addresses are longer than MAC addresses
    Show the answer

    A. A MAC address identifies a network interface on the local link (48 bits, set by the maker); an IP address identifies a host across networks and changes as the host moves between networks

    Frames on a LAN are delivered by MAC address, and packets travel between networks by IP address; ARP links the two on the local network. At every router hop the MAC addresses in the frame change while the IP addresses in the packet stay the same (NAT aside). An IPv4 address is 32 bits.

    This topic is named in a candidate’s interview report: Intern on-campus interview, 2024, on GeeksforGeeks.

  6. Computer networksMedium

    On a shared, half-duplex Ethernet segment, what does a station do when it detects a collision while sending?

    1. It keeps sending and leaves the receiver to fix it
    2. It stops, sends a jam signal, waits a random backoff time that grows with each collision, and tries again
    3. It switches to another frequency
    4. It asks the switch for permission to send
    Show the answer

    B. It stops, sends a jam signal, waits a random backoff time that grows with each collision, and tries again

    This is CSMA/CD: listen before sending, detect collisions, back off. After the n-th collision the station waits a random number of slot times from 0 to 2^n - 1 (binary exponential backoff). Full-duplex switched Ethernet has no collisions, and Wi-Fi uses CSMA/CA, avoiding them because it cannot detect them.

    This topic is named in a candidate’s interview report: Intern on-campus interview, 2024, on GeeksforGeeks.

Prep for other employers

All employers
See who is hiring after Marvell Technology

Engineering internships and entry-level jobs in India, newest first.