<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Algorithm &#8211; Taiziii Co., Ltd.</title>
	<atom:link href="https://taiziii.com/en/column_cat/algorithm-en/feed/" rel="self" type="application/rss+xml" />
	<link>https://taiziii.com</link>
	<description>事業理解に強いITコンサルタントとフルスタックエンジニアが、Webサービス・アプリ・業務システムを戦略設計から実装・保守運用まで一気通貫で支援。AI活用や内製化支援で成果に直結する開発を実現します。</description>
	<lastBuildDate>Wed, 19 Feb 2025 16:18:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://taiziii.com/wp-content/uploads/2023/10/favicon.ico</url>
	<title>Algorithm &#8211; Taiziii Co., Ltd.</title>
	<link>https://taiziii.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>7 Must-Know Critical Data Structures You Absolutely Need to Understand!</title>
		<link>https://taiziii.com/en/column/1131/</link>
		
		<dc:creator><![CDATA[THiNGMAjiG_admin_user_master]]></dc:creator>
		<pubDate>Wed, 19 Feb 2025 16:18:08 +0000</pubDate>
				<guid isPermaLink="false">https://taiziii.com/?post_type=column&#038;p=1131</guid>

					<description><![CDATA[This time, it&#8217;s about data structures! Let&#8217;s learn about the mechanisms and features of data structures! What You Can Learn in This Article ・The basic mechanisms and features of data structures Introduction There are various types of data structures, and each has its own advantages and disadvantages. Therefore, it is essential to choose the right [&#8230;]]]></description>
										<content:encoded><![CDATA[<div class="balloonWrap">
<div class="balloon2-left">
<p>This time, it&#8217;s about data structures!</p>
</div>
<div class="balloon2-right">
<p>Let&#8217;s learn about the mechanisms and features of data structures!</p>
</div>
</div>
<h2>What You Can Learn in This Article</h2>
<p>・The basic mechanisms and features of data structures</p>
<h2>Introduction</h2>
<p>There are various types of data structures, and each has its own advantages and disadvantages. Therefore, it is essential to choose the right data structure according to the program&#8217;s requirements. In this article, we aim to introduce the characteristics of various data structures, expanding the reader&#8217;s options and providing criteria for making informed choices.<br />
Now, let&#8217;s get into the main topic. First, I&#8217;d like to explain what a data structure is.</p>
<h2>What is a Data Structure?</h2>
<p>A data structure refers to a formalized way of organizing and managing a collection of data in a specific format for a particular purpose. Data structures improve the performance of programs by enabling efficient searching, adding, deleting, and updating of data.<br />
The choice of data structure has a significant impact on the performance of a program. By choosing the right data structure, you can improve execution speed and reduce memory usage. Moreover, the selection of a data structure also affects the maintainability of the program. A well-chosen data structure makes the code easier to understand and modify.<br />
Now, let&#8217;s introduce specific data structures.</p>
<h2>List</h2>
<p>A list is a data structure used to store multiple elements in a specific order. Let&#8217;s explain it in detail with an example of a list consisting of three elements.</p>
<p><img decoding="async" class="alignnone size-medium wp-image-407 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-21.49.28-300x50.png" alt="" width="300" height="50" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-21.49.28-300x50.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-21.49.28-768x129.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-21.49.28.png 932w" sizes="(max-width: 300px) 100vw, 300px" ><br />
In a list, each node typically contains data and a pointer to the next node. In this example, the first two nodes contain Apple and a pointer, and Peach and a pointer, respectively. Note that the node containing Lemon does not have a pointer, as it is the last node, and there is no node after it.<br />
Each node can only be accessed by following the pointers from the head. In this case, to access Lemon, you must first access Apple and then follow the pointer to Peach.<br />
Adding data is easy since it only requires changing the pointers of the surrounding nodes. For example, to insert Mango between Peach and Lemon, you simply change Peach&#8217;s pointer to point to Mango and Mango&#8217;s pointer to Lemon.</p>
<p><img decoding="async" class="alignnone size-medium wp-image-408 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.06.16-300x119.png" alt="" width="300" height="119" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.06.16-300x119.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.06.16-768x304.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.06.16.png 950w" sizes="(max-width: 300px) 100vw, 300px" ><br />
Data deletion is also easy, similar to adding data, by changing the pointers. For example, to delete Mango, you simply change Peach&#8217;s pointer to point to Lemon.<br />
In summary, lists are easy to add or delete data, but accessing data takes time. Here, we explained the basic mechanism of a singly linked list, but there are also other types, such as circular lists where the last node points to the first node, and doubly linked lists where each node has two pointers pointing to the previous and next nodes.</p>
<h2>Array</h2>
<p>An array stores data in a sequence. If an array named &#8216;a&#8217; contains three pieces of data, the brackets next to &#8216;a&#8217; represent the index of the array.</p>
<p><img decoding="async" class="alignnone size-medium wp-image-409 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.22.33-300x72.png" alt="" width="300" height="72" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.22.33-300x72.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.22.33-768x186.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.22.33.png 1018w" sizes="(max-width: 300px) 100vw, 300px" ><br />
In an array, you can directly access the data by specifying the index. For example, to access Lemon, you simply specify a[2].<br />
Adding data in an array is more costly than in a list. To add Mango to a[1], for example, first, you need to allocate space at the end of the array.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-410 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.40-300x113.png" alt="" width="300" height="113" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.40-300x113.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.40-1024x384.png 1024w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.40-768x288.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.40.png 1082w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
Then, to make room for the new data, you need to shift the existing data one by one. In this case, you would first move Lemon, then Peach, and finally place Mango at a[1].</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-411 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.48-300x103.png" alt="" width="300" height="103" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.48-300x103.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.48-1024x352.png 1024w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.48-768x264.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-12-22.39.48.png 1060w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
To delete data, you reverse the process. For example, to delete Mango, you remove it and then shift Peach and Lemon to the right.<br />
Arrays allow easy access to data, but adding or deleting data can be costly.</p>
<h2>Stack</h2>
<p>A stack is a data structure that follows the LIFO (Last In, First Out) principle. Data added later is removed first. In a stack, adding data is called &#8220;push&#8221; and removing data is called &#8220;pop.&#8221;<br />
For example, if you push Apple and then push Peach, the result would be as follows:</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-421 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.37.11-300x147.png" alt="" width="300" height="147" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.37.11-300x147.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.37.11-1024x502.png 1024w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.37.11-768x376.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.37.11.png 1216w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
When you pop, Peach is removed.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-426 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.47.43-300x136.png" alt="" width="300" height="136" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.47.43-300x136.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.47.43-1024x464.png 1024w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.47.43-768x348.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.47.43.png 1100w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
A stack is useful when you always need access to the most recently added data but doesn&#8217;t allow access to intermediate data.</p>
<h2>Queue</h2>
<p>A queue is a data structure that follows the FIFO (First In, First Out) principle. Data added earlier is removed first. In a queue, adding data is called &#8220;enqueue&#8221; and removing data is called &#8220;dequeue.&#8221;<br />
For example, if you enqueue Apple and then enqueue Peach, the result would be as follows:</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-423 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.44.33-300x131.png" alt="" width="300" height="131" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.44.33-300x131.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.44.33-1024x446.png 1024w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.44.33-768x334.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.44.33.png 1208w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
At this point, it&#8217;s similar to a stack. However, when you dequeue, Apple is removed.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-425 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.46.13-300x122.png" alt="" width="300" height="122" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.46.13-300x122.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.46.13-1024x416.png 1024w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.46.13-768x312.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.46.13.png 1196w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
A queue, like a stack, doesn&#8217;t allow access to intermediate data but is useful when you need to process data in the order it was added.</p>
<h2>Hash Table</h2>
<p>A hash table is a data structure that uses a hash function to efficiently search for data consisting of key-value pairs. For example, consider storing a [key, value] pair like [Taro, Male] in an array with five boxes.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-428 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.50.43-300x131.png" alt="" width="300" height="131" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.50.43-300x131.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.50.43-1024x447.png 1024w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.50.43-768x335.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.50.43.png 1168w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
First, the key &#8220;Taro&#8221; is converted using the hash function. The result is 3569 (this is called the hash value).</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-429 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-13-21.57.07-1-300x70.png" alt="" width="300" height="70" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-13-21.57.07-1-300x70.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-13-21.57.07-1-768x179.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-13-21.57.07-1.png 790w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
When you apply the modulus operation with 5 (since the array has five boxes), 3569 equals 4. Therefore, [Taro, Male] is stored in the 4th box.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-430 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.52.54-300x130.png" alt="" width="300" height="130" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.52.54-300x130.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.52.54-1024x442.png 1024w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.52.54-768x332.png 768w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.52.54.png 1200w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
Next, consider the data [Hanako, Female]. When you hash &#8220;Hanako&#8221; and apply the modulus operation, if the result is 0 to 3, it is stored in the corresponding box. If the result is 4, the data is linked to [Taro, Male] in the same box using a list.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-436 lazyload" data-src="http://thingmajig.jp.testhosting.work/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.59.15-300x147.png" alt="" width="300" height="147" data-srcset="https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.59.15-300x147.png 300w, https://taiziii.com/wp-content/uploads/2023/08/スクリーンショット-2023-08-14-22.59.15.png 614w" sizes="auto, (max-width: 300px) 100vw, 300px" ><br />
A hash table can quickly retrieve data by using the key.</p>
<h2>Conclusion</h2>
<p>This time, we introduced some basic data structures such as lists, arrays, stacks, queues, and hash tables. We also touched on their mechanisms and features.<br />
To choose the right data structure for your program, you need to understand the advantages and disadvantages of each one. If you need fast data retrieval and flexibility, hash tables are great, while for sequential processing, lists or arrays may be better. Furthermore, if you need to process data in a specific order, stacks and queues can be useful.<br />
Now that you know the characteristics of different data structures, you can choose the best one according to your needs. Happy coding!</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
