0% found this document useful (0 votes)
8 views5 pages

It - NM Assign 6

The document analyzes various data structures for efficiently tracking user orders on a website, recommending a Hash Table for its constant-time lookups. It also discusses the incorporation of non-linear data structures to enhance application performance, particularly in database queries and web crawling. Additionally, it highlights non-linear programming techniques like Gradient Descent and Newton's Method for optimizing complex problems.

Uploaded by

24f1002292
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

It - NM Assign 6

The document analyzes various data structures for efficiently tracking user orders on a website, recommending a Hash Table for its constant-time lookups. It also discusses the incorporation of non-linear data structures to enhance application performance, particularly in database queries and web crawling. Additionally, it highlights non-linear programming techniques like Gradient Descent and Newton's Method for optimizing complex problems.

Uploaded by

24f1002292
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Reg.

No 313522205020 NM - Stream Design Thinking


Name HARISH.R Assignment No 6
Year & Sem II Year & IV Sem Submission Date 22.04.2024
Department B.Tech – Information Technology Module 6
Gmail ID’S [email protected] Total Pages 5

1. Analyze a website that tracks user orders, suggest appropriate data structure to be used
for efficient search of items in the website. List down the time and space complexity of the
suggestion provided.
Let’s analyze the requirements for efficiently searching user orders on a website and recommend an
appropriate data structure. We’ll consider both time and space complexities.
a) Binary Search Tree (BST):
o Description: A BST is a tree-based data structure where each node has at most two
children: a left child (with a value less than the parent) and a right child (with a value
greater than the parent).
o Efficiency:
▪ Search Time Complexity: O(log n) on average (assuming a balanced tree).
▪ Space Complexity: O(n) to store n elements.
o Advantages:
▪ Efficient search for arbitrary elements.
▪ Maintains order (useful for range queries).
o Considerations:
▪ Ensure the tree remains balanced (e.g., AVL tree or Red-Black tree) to
maintain efficiency.
b) Hash Table (HashMap):
o Description: A hash table uses a hash function to map keys to indices in an array. It
provides fast access to values based on their keys.
o Efficiency:
▪ Search Time Complexity: O(1) on average (assuming a good hash function
and minimal collisions).
▪ Space Complexity: O(n) to store n key-value pairs.
o Advantages:
▪ Extremely fast lookups.
▪ Ideal for direct key-based access.
Reg. No 313522205020 NM - Stream Design Thinking
Name HARISH.R Assignment No 6
Year & Sem II Year & IV Sem Submission Date 22.04.2024
Department B.Tech – Information Technology Module 6
Gmail ID’S [email protected] Total Pages 5

o Considerations:
▪ Handle hash collisions (e.g., using chaining or open addressing).
c) Trie (Prefix Tree):
o Description: A trie is a tree-like data structure used for efficient string matching and
retrieval.
o Efficiency:
▪ Search Time Complexity: O(m), where m is the length of the search key.
▪ Space Complexity: O(n * m), where n is the number of orders and m is the
average order length.
o Advantages:
▪ Efficient for prefix-based searches (e.g., searching for order numbers).
▪ Space-efficient for common prefixes.
o Considerations:
▪ May consume more memory due to branching.
d) Bloom Filter:
o Description: A probabilistic data structure that tests whether an element is a member
of a set.
o Efficiency:
▪ Search Time Complexity: O(1) (approximate, with a small false positive rate).
▪ Space Complexity: Depends on the desired false positive rate.
o Advantages:
▪ Extremely memory-efficient.
▪ Useful for filtering out non-existent orders.
o Considerations:
▪ May produce false positives (i.e., indicating an order exists when it doesn’t).
e) Balanced Binary Search Tree (e.g., AVL Tree):
o Description: An extension of BST that ensures the tree remains balanced.
o Efficiency:
▪ Search Time Complexity: O(log n) even in worst-case scenarios.
Reg. No 313522205020 NM - Stream Design Thinking
Name HARISH.R Assignment No 6
Year & Sem II Year & IV Sem Submission Date 22.04.2024
Department B.Tech – Information Technology Module 6
Gmail ID’S [email protected] Total Pages 5

▪ Space Complexity: O(n).


o Advantages:
▪ Efficient search.
▪ Guaranteed balanced structure.
o Considerations:
▪ Slightly more complex to implement than a basic BST.
Recommendation: Considering the need for efficient search and assuming that order numbers are
unique, I recommend using a Hash Table (Hash Map). It provides constant-time lookups and is
well-suited for direct key-based access to user orders. Ensure proper handling of hash collisions to
maintain efficiency.
Reg. No 313522205020 NM - Stream Design Thinking
Name HARISH.R Assignment No 6
Year & Sem II Year & IV Sem Submission Date 22.04.2024
Department B.Tech – Information Technology Module 6
Gmail ID’S [email protected] Total Pages 5

2. Code of an application is shared. The speed of the application is of a major concern as


linear data structures are used. Modify the application code shared to include non-linear
data structures and check the application performance.
Let’s address the performance concerns by incorporating non-linear data structures into the
application code. We’ll explore some common scenarios where non-linear structures can enhance
efficiency:
a) Database Query Optimization:
o Non-Linear Structure: Use graph-based structures to optimize complex database
queries. These structures determine efficient access paths and join strategies, leading
to faster query execution1.
o Example: When retrieving related data from multiple tables, a graph-based approach
can efficiently traverse relationships.
b) Web Crawlers and Search Engines:
o Non-Linear Structure: Graph-based structures are essential for web crawling,
indexing, and ranking in search engines.
o Example: Search engines use graphs to represent web pages and their links, enabling
efficient retrieval of relevant information.
c) Fuel Efficiency Optimization (Real-World Example):
o Scenario: Imagine a car manufacturer aiming to optimize fuel efficiency in vehicle
design.
o Objective: Maximize fuel economy while considering non-linear factors like
aerodynamics, tire friction, and engine performance.
o Need for Non-Linear Programming:
▪ The relationship between variables (e.g., engine power, weight, aerodynamic
coefficient) and the objective function is not simple or linear.
▪ Non-linear programming techniques are crucial for solving such complex
optimization problems.
Reg. No 313522205020 NM - Stream Design Thinking
Name HARISH.R Assignment No 6
Year & Sem II Year & IV Sem Submission Date 22.04.2024
Department B.Tech – Information Technology Module 6
Gmail ID’S [email protected] Total Pages 5

d) Non-Linear Programming Techniques:


o Gradient Descent:
▪ An iterative method adjusting design variables based on the gradient of the
objective function.
▪ Fine-tunes parameters by moving toward the steepest descent in the function
space.
o Newton’s Method:
▪ Another iterative technique using second-order derivatives (Hessian matrix)
along with the gradient.
▪ Guides optimization by considering curvature in addition to the gradient

You might also like