<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Geminiixd</title>
    <description>The latest articles on DEV Community by Geminiixd (@geminiixd).</description>
    <link>https://dev.to/geminiixd</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1052862%2F0ebcc946-6f7c-4c5b-a2c0-6cbd5d0baaa8.jpg</url>
      <title>DEV Community: Geminiixd</title>
      <link>https://dev.to/geminiixd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/geminiixd"/>
    <language>en</language>
    <item>
      <title>Data structures in Computer Science</title>
      <dc:creator>Geminiixd</dc:creator>
      <pubDate>Sun, 02 Apr 2023 18:46:13 +0000</pubDate>
      <link>https://dev.to/geminiixd/data-structures-in-computer-science-158g</link>
      <guid>https://dev.to/geminiixd/data-structures-in-computer-science-158g</guid>
      <description>&lt;h3&gt;
  
  
  Data structures
&lt;/h3&gt;

&lt;h2&gt;
  
  
  What is a data structure?
&lt;/h2&gt;

&lt;p&gt;Data structure is a particular pattern for organizing info in a way, so we will be able to interact with it in the fastest way possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arrays in Data Structure
&lt;/h2&gt;

&lt;p&gt;so, maybe for some people the first question that comes to your mind is that, what's an array? The answer is simple. An array is a data structure organized as a linear collection of elements for which is a index which is a numerical interactor of position used for accessing content. In Arrays the same info may appear more than once, but in a different index!&lt;/p&gt;

&lt;p&gt;Here is an example that i created. As you can see there are 2 starred numbers that are the same but, the indexes are different!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6iSGX_2T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2po00cy7lozgq5uhy11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6iSGX_2T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2po00cy7lozgq5uhy11.png" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can differentiate between arrays based on whether their size is declared up-front/static or able to change at run time (dynamic).&lt;/p&gt;

&lt;p&gt;Most people who code must know about arrays and how they are useable in programming languages.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;//Java&lt;br&gt;
int[] myArray = {1, 2, 3};Array&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;//C++&lt;br&gt;
int Array[] = {1, 2, 3};&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;//Python&lt;br&gt;
from array import array&lt;br&gt;
myArray = array('i', [1, 2, 3])&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Or we can declare empty arrays of different size (I will use 3 here)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;//Java&lt;br&gt;
int[] myArray = new int[3];&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;//C++&lt;br&gt;
int Array[3];&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Stack Data Structure
&lt;/h2&gt;

&lt;p&gt;A stack is a collection of objects optimized for 2 elements:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Adding items&lt;/li&gt;
&lt;li&gt;Removing the most recent-added item in the list first&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The items are inserted and removed according to the last-in, fist-out (LIFO)&lt;/p&gt;

&lt;p&gt;Example: Imagine Putting 3 trays in the oven, the last tray (The one at the highest floor) is the first out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stack ADT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;independent of any language, a stack data structure should provide the following update methods&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;push(e): Adds the element called "e" to the top of the stack.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;pop(): If the stack is not empty, it removes and returns the top element&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;there are also other methods we call helpers: top(): returns the top element. &lt;br&gt;
isEmpty(): Returns true if there are no elements in the stack, otherwise, returns false.&lt;/p&gt;

&lt;p&gt;size(): Returns the number of elements in the stack.&lt;/p&gt;

&lt;h2&gt;
  
  
  Queue Data Structure
&lt;/h2&gt;

&lt;p&gt;This structure is a collection of objects which is optimized for adding new objects to the collection ad removing the oldest object from the collection, therefore the first object-in will be the first object-out (FIFO)&lt;/p&gt;

&lt;p&gt;Example: Imagine a shop line, the first person in the line is the first person out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Queue stacks update methods&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;enqueue(e): Adds "e" to the end of the queue.&lt;/li&gt;
&lt;li&gt;dequeue(): Removes and returns the element at the front of the queue or returns null if the queue is empty.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Accessor Methods&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;size(): Returns the number of elements in the queue.&lt;/li&gt;
&lt;li&gt;isEmpty(): Returns true if the queue is empty.&lt;/li&gt;
&lt;li&gt;first(): Returns the element at the front of the queue.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Queue options in programming languages&lt;/strong&gt; (Didn't write every language)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;//Javascript:
supports the push and shift methods which is able to emulate the behavior of the behavior of a queue.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, these were Most of the basics of Data structure used in computer science and is a must know for people who are interested in Computer Science&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>datascience</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
