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
-
For a positive integer n, what does (n & (n - 1)) == 0 tell you?
- n is even
- n is odd
- n has exactly two set bits
- 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.
-
How do you print every root-to-leaf path of a binary tree?
- A level-order traversal printing each level
- A DFS that adds each node to a current path, prints the path at a leaf, and removes the node again when it returns
- Sort the nodes and print them
- 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
-
What does this print?
unsigned n = 44; int count = 0; while (n) { n &= n - 1; count++; } printf("%d", count);- 6
- 4
- 2
- 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.
-
What does this print?
int a[] = {5, 10, 15, 20}; int *p = a + 1; printf("%d %d %d", *p + 1, *(p + 1), p[2]);- 11 15 20
- 15 15 20
- 6 15 20
- 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
-
What is the TTL field in an IP packet for?
- Each router lowers it by one and drops the packet at zero, so packets cannot loop forever
- It sets how long a website may cache the page
- It is the packet's timestamp
- 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.
-
How does an Ethernet switch learn which of its ports leads to which device?
- 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
- It asks the DHCP server
- It reads the IP address in each packet
- 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.
-
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?
- 3 fragments; last offset 2,960
- 2 fragments; last offset 185
- 3 fragments; last offset 370
- 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.
-
How does traceroute find the routers along the path to a host?
- It asks each router for its routing table
- It looks each router up in DNS
- 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
- 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.
-
How does a MAC address differ from an IP address?
- 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
- They are two names for the same number
- MAC addresses are used across the internet and IP addresses only inside a LAN
- 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.
-
On a shared, half-duplex Ethernet segment, what does a station do when it detects a collision while sending?
- It keeps sending and leaves the receiver to fix it
- It stops, sends a jam signal, waits a random backoff time that grows with each collision, and tries again
- It switches to another frequency
- 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.