Hard Graph Traversal and Data Storage | Solve |
Consider the following pseudo code implementing a specific graph traversal algorithm:
What is the order in which the nodes are processed, and which data structure best represents the graph `G` for efficient traversal?
|
Medium Implementing a Browser's Back Button | Solve |
You are tasked with implementing the "Back" button functionality in a web browser. This feature allows users to return to previously visited web pages in the order they were viewed. The browser maintains a history of URLs in a data structure. Considering the nature of web browsing, where users can go back multiple steps and then navigate to a new page (at which point the future history should be cleared), which data structure and algorithm would best implement this functionality?
A: Use a heap, add the current URL when navigating to a new page, and remove the top element when the back button is used.
B: Use a queue, enqueue the current URL when navigating to a new page, and dequeue when the back button is used.
C: Use a single stack, push the current URL when navigating to a new page, and pop when the back button is used.
D: Use an array, add the current URL to the end when navigating to a new page, and remove the last URL when the back button is used.
E: Use a linked list, add the current URL to the head when navigating to a new page, and move backwards when the back button is used.
F: Use two stacks, push the current URL to the first stack when navigating to a new page, and use the second stack to store the pages when the back button is used.
|
Easy Linked List Element Removal | Solve |
Consider a singly linked list where each node contains an integer value. Write a function `removeElement` that removes all occurrences of a specific value from the linked list. The function should return the head of the modified linked list.
Pseudo code:
What will be the content of the linked list referred to by `result` after executing the above pseudo code?
|
Medium Decryptor | Solve |
What does the following pseudo code print?
|
Hard Fibonacci codes | Solve |
Here are three pseudocodes for calculating the Nth Fibonacci number. Which of the following statements about these codes are true?
A: Time complexity/efficiency of CODE 1, CODE 2, CODE 3 is the same.
B: CODE 2 is more space-efficient than CODE 3.
C: CODE 3 is more space-efficient than CODE 2.
D: CODE 2 is more time-efficient than CODE 1.
E: CODE 3 is more time-efficient than CODE 1.
|
Hard Palindrome Test cases | Solve |
Go through the following faulty palindrome detection pseudocode and test cases. For which of the test cases would the code return true?
Testcases
A: a
B: aba
C: aaa
D: aac
|
Medium Rewards Activities Order | Solve |
A new popular app tracks the activities performed by its users and grants them rewards based on each individual's total activities performed in a year. This data is maintained in a database table (activitesinfo), with the following columns: userid, totalactivities, reward. This year, due to fundraising activity, the company has decided to further reward its users by enhancing the reward as per the following formula: If reward < = 4000, increase it by 2%, If 4000 < reward <= 8000, increase it by 4%, If reward > 8000, increase it by 6%.
The tech team has written three different scripts to calculate increment for each slab, each script is to run as a separate transaction. Here are the three scripts:
Script 1:
For users with reward <= 4000, set reward = reward * 1.02
Script 2:
For users with reward > 4000 and reward <= 8000, set reward = reward * 1.04
Script 3:
For users with reward > 8000, set reward = reward * 1.06
Each script is to be executed separately. Which of the following options will update the rewards as expected:
A: Execute Script 1 followed by Script 2 followed by Script 3
B: Execute Script 2 followed by Script 3; Script 1 running concurrently throughout
C: Execute Script 3 followed by Script 2; Script 1 running concurrently throughout
D: Execute Script 3 followed by Script 2 followed by Script 1
E: Execute Script 2 followed by Script 3 followed by Script 1
|
Medium Optimal Data Replication and Consistency in Distributed Systems | Solve |
Consider a distributed e-commerce platform designed to handle high traffic volumes and ensure data consistency across its services. The platform uses a distributed database that replicates data across multiple nodes to increase availability and performance. To balance the load, it employs a load balancer that distributes user requests evenly across these nodes. The system is designed to tolerate the failure of up to two nodes without affecting the platform's overall availability.
Given the critical requirement for strong consistency to prevent issues such as overselling of products, the system uses a consensus algorithm for replication. The database is configured with a replication factor of 5, meaning each piece of data is stored on 5 nodes. For read and write operations to be considered successful, they must be acknowledged by a majority of the nodes involved in the operation.
Assuming all nodes have equal hardware resources and network latency between nodes is negligible, which of the following configurations would best meet the platform's requirements for high availability, performance, and strong consistency?
A: Reads require acknowledgment from 2 nodes, and writes require acknowledgment from 4 nodes.
B: Reads and writes both require acknowledgment from 3 nodes.
C: Reads require acknowledgment from 3 nodes, and writes require acknowledgment from 2 nodes.
D: Reads and writes both require acknowledgment from 4 nodes.
E: Reads require acknowledgment from 1 node, and writes require acknowledgment from 5 nodes.
F: Reads and writes both require acknowledgment from 5 nodes.
|
Easy Real-time Vehicle Tracking for Logistics Company | Solve |
TransitTrack is a logistics company that needs to store real-time location data (latitude, longitude) of their vehicles as they move across the city. The system should be optimized for fast read and write operations to provide real-time tracking. TransitTrack can tolerate occasional data loss since the vehicle locations are updated frequently. Which of the following data storage solutions should TransitTrack implement for their vehicle tracking system?
A: Utilize a relational database management system (RDBMS) like PostgreSQL with a table indexed on the vehicle_id column for efficient data insertion and retrieval.
B: Implement an in-memory cache like Redis to store the vehicle location data, with the vehicle_id as the key and the latitude-longitude pair as the value.
C: Use a document-oriented database like MongoDB to store the vehicle location data as GeoJSON documents, enabling geospatial querying capabilities.
D: Develop a custom in-memory data structure using a spatial indexing technique like an R-tree to store and query the vehicle location data efficiently.
E: Use a time-series database like InfluxDB to store the vehicle location data along with timestamps, allowing for efficient querying and analysis of historical location data.
|
Medium Session stickiness with ELB | Solve |
Johnny Bravo is setting up a new e-commerce store for men's clothing. He set up session stickiness with ELB. But he does not want ELB to manage the cookie, he wants the application to manage the cookie. When the server instance, which is bound to a cookie, crashes what do you expect will happen?
A: ELB will throw an error due to cookie unavailability
B: The response will have a cookie but stickiness will be deleted
C: The session will be sticky and ELB will route requests to another server as ELB keeps replicating the Cookie
D: The session will not be sticky until a new cookie is inserted
|
Medium Updating UI after Encoding | Solve |
Imagine you’re a developer at Songbird Inc, working on a music editing app for mobile devices. The app allows users to edit audio clips and export them in various audio formats. Once a user finishes editing a clip, they can choose an output format and initiate the encoding process. This encoding process can take a while depending on the chosen format and the length of the clip. Because it’s a mobile app, you want to avoid freezing the UI while encoding is in progress.
What’s the most appropriate approach to notify the user when the encoding is complete and the exported file is ready?
A: Directly modify the UI elements from within the encoding logic. When encoding finishes, the encoding system can directly tell the UI components to update themselves with the new information (e.g., change a button text to “Export Complete”).
B: Separate the UI update logic from the encoding process. The encoding system should trigger a custom event (e.g., “EncodingFinishedEvent”) upon completion. UI components can listen for this event and update themselves accordingly when it’s received.
C: Have the UI code continuously check on the encoding status with a loop (often referred to as busy waiting or polling). The loop would keep checking a flag or variable set by the encoding system until the encoding is complete. Once complete, the UI can update itself.
D: Introduce a central message queue or event bus. The encoding system can publish a message to the message queue upon finishing the task. Separate UI update logic would be subscribed to the queue, listening for relevant messages. When it receives the message about encoding completion, it can update the UI.
E: Let the encoding logic return a callback function to the UI layer when it’s initiated. Once encoding is finished, the encoding system calls back this function, allowing the UI to update itself.
|
Medium Mac address and IP on router hop | Solve |
Refer to the following exhibit:
Host A is sending a packet to Host B.
1. What is the source and destination MAC address at point PA?
2. What is the source and destination IP address at point PB?
// Option A
PA: source MAC - Mac-A
PA: destination MAC - Mac-B
PB: source IP - 192.168.1.1
PB: destination IP - 192.168.3.1
// Option B
PA: source MAC - Mac-A
PA: destination MAC - Mac-RA
PB: source IP - 192.168.3.3
PB: destination IP - 192.168.3.1
// Option C
PA: source MAC - Mac-A
PA: destination MAC - Mac-B
PB: source IP - 192.168.3.3
PB: destination IP - 192.168.3.1
// Option D
PA: source MAC - Mac-A
PA: destination MAC - Mac-RA
PB: source IP - 192.168.1.1
PB: destination IP - 192.168.3.1
|
Easy MX Record, DMARC and Email Authentication | Solve |
You work as a network administrator for a company, "example.com", that recently started experiencing issues with email spoofing. To mitigate the problem, you decide to implement DMARC (Domain-based Message Authentication, Reporting & Conformance) in addition to existing SPF (Sender Policy Framework) and DKIM (DomainKeys Identified Mail) records.
Your current DNS records for example.com include the following:
- MX 10 mail.example.com (IP address 203.0.113.10)
- TXT "v=spf1 ip4:203.0.113.10 -all"
- TXT "v=DKIM1; k=rsa; p=public-key-here"
You add the following DMARC record:
- TXT "_dmarc.example.com" "v=DMARC1; p=quarantine; pct=100; rua=mailto:report@example.com"
After implementing the DMARC record, an external mail server sends an email to your domain. The email passes the SPF and DKIM checks but fails the DMARC check.
What will likely happen to the email?
A: The email will be accepted and delivered to the recipient's inbox.
B: The email will be rejected and returned to the sender as undeliverable.
C: The email might be delivered to the recipient's spam or junk folder.
D: The email will be accepted, but a report will be sent to the sender.
E: The email will be silently discarded, and the sender will not be notified.
|
Medium Remote network resources | Solve |
Review the following exhibit:
Angelina noticed that the computers on 192.168.10.0/24 network can ping their default gateway. But they found that these computers cannot connect to any remote network resources. Which of the following is the most likely reason for this?
|
Medium SSL Certificate Expiry | Solve |
You are a network administrator for an e-commerce company. The company's online store allows customers to browse products and make purchases securely over the internet. The online store uses SSL/TLS for secure communication. You receive reports that some customers are seeing a security warning in their web browsers when trying to access the online store. Upon investigation, you discover the following information:
- The SSL certificate used by the online store's web server is valid for one year and is due to expire in two days.
- The web server is configured to automatically redirect HTTP traffic to HTTPS.
- The SSL certificate was issued by a trusted certificate authority (CA), and all major web browsers have the CA's root certificate in their trusted certificate stores.
- The SSL certificate includes the correct domain name for the online store.
Given the above information, which of the following steps should be taken to resolve the issue and prevent customers from seeing the security warning?
A: Extend the validity of the current SSL certificate by one year.
B: Obtain a new SSL certificate from the same CA and install it on the web server before the current certificate expires.
C: Remove the automatic redirect from HTTP to HTTPS on the web server.
D: Ask customers to ignore the security warning and proceed to the online store.
E: Replace the SSL certificate with a self-signed certificate.
|