Why DSA? And How?
I have nearly completed an intensive five-week college course detailing the preliminary and general concepts of data structures and algorithms (DSA). We discussed arrays, searches, sorts, abstract data types (ADT), binary trees, and efficiency metrics, and implemented them in Java. When DSA is used, a relevant inquiry is made about whether some algorithms and data structures are better. The short answer is yes. In many cases, the more information is stored and manipulated, the more efficiency can be disrupted by inefficient algorithms. How do we choose between them? Shaffer teaches that an algorithm should be simplistic and designed for easier comprehension by code readers and for debugging (Shaffer, 2013, p. 3). Additionally, efficient algorithms and data structures use the computer’s resources efficiently (Shaffer, 2013, p. 3). When these two characteristics of efficient code are achieved simultaneously, the program is said to be “elegant” (Shaffer, 2013, p. 4). Specific metrics for analyzing efficiency are time and space complexity. Time complexity refers to the amount of time a particular portion of an algorithm takes regarding input. In contrast, space complexity refers to the amount of memory being used, though space complexity is sometimes apparent or inconsequential and can be ignored (University of Texas, n.d.).
Applying DSA Techniques while Developing Structured Programs.
As a newbie to DSA, there are some simple and complicated considerations to make when developing structured programs. Both complexity metrics discussed above focus on allowing asymptotic analysis, meaning the input is repeated until infinity. These metrics are imperative in the world of information technology and programming. Understanding the rules of Θ (theta), O (big-Oh), and Ω (omega) in complexity analysis is imperative in properly analyzing algorithms for efficiency. I have had exposure to Cliff Shaffer’s Data Structures and Algorithm Analysis, Edition 3.2 – Java Version, and I highly recommend getting a copy to get full exposure to these techniques. Here is a link to that resource → (https://people.cs.vt.edu/~shaffer/Book/JAVA3elatest.pdf)
I also advise understanding the ADTs being used and applying
them appropriately. For instance, class methods such as pop and peek should be
applied carefully when using stacks and queues. If you have an empty stack or
queue and use specific techniques to interact with them (such as peek or pop),
you will have an exception thrown (Luthra, 2023). In that respect, knowing the
difference between add and offer is helpful, or peek and element. Add and offer
complete the same task, but the .offer() method does not throw exceptions if a
queue is empty (Geeks for Geeks 2022). Similarly, the .peek() method will not
throw an exception but return null (Tutorials Point, 2022). Stacks and queues
are lists of items, but the stack ADT is LIFO (last in, first out), and the
queue ADT is FIFO (first in, first out). “Stacks are one of the most widely
used collection types in computer science. A tiny fraction of their known uses:
page history in a browser, undo/redo, vending machines, navigating a maze,
backtracking algorithms trying out different alternatives, and function calls
in a running program” (Loyola Marymount University, n.d., Section: The Basics).
In summary, understanding the tools of the language and, in general,
object-oriented programming supplements DSA techniques.
References
Geeks
for Geeks. (2022, November 17). Difference between add() and offer() methods in
Queue in Java.
https://www.geeksforgeeks.org/difference-between-add-and-offer-methods-in-queue-in-java/
Loyola
Marymount University. (n.d.). Stacks. Retrieved from
http://cs.lmu.edu/~ray/notes/stacks/
Luthra,
T. (2023, October 2). Java stack peek() method with examples. Scaler Topics.
https://www.scaler.com/topics/peek-in-stack/
Shaffer,
C. A. (2013). Data structures and algorithm analysis. (Edition 3.2). Retrieved
from http://people.cs.vt.edu/~shaffer/Book/JAVA3elatest.pdf
Tutorials
Point. (2022, May 06). Difference between peek(), poll() and remove() method of
Queue interface in java?
https://www.tutorialspoint.com/difference-between-peek-poll-and-remove-method-of-queue-interface-in-java
University
of Texas. (n.d.) Complexity analysis. Retrieved from
http://www.cs.utexas.edu/users/djimenez/utsa/cs1723/lecture2.html

Comments
Post a Comment