[{"data":1,"prerenderedAt":89},["ShallowReactive",2],{"blog-nauka-struktur-danych":3},{"title":4,"description":7,"image":10,"category":11,"featured":12,"isPublished":13,"publishDate":14,"author":15,"links":16,"projects":17,"mainLanguage":18,"viewCount":19,"value":20,"content":21,"tableOfContents":24},{"en":5,"pl":6},"Learning data structures","Nauka struktur danych",{"en":8,"pl":9},"A practical guide to the most important data structures: arrays, linked lists, hash tables, sets, stacks, queues, trees, and graphs with Big O complexity.","Praktyczny przewodnik po najważniejszych strukturach danych: tablice, listy, tablice hashujące, zestawy, stosy, kolejki, drzewa i grafy ze złożonością Big O.","https://files.jtuta.cloud/public/portfolio/blogs/bQmBB8MjywQk4VyuvHyGVsB2LXURpj.png","algorithms",false,true,"2025-08-28T21:17:53.474Z",null,[],[],"pl",2,"nauka-struktur-danych",{"en":22,"pl":23},"\u003Cp>﻿## Introduction\u003C/p>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/5BJYLX6YJUQF4wXikNINDSCDZNvpQk.jpg\" alt=\"Learning data structures\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>The \u003Cem>O(n)\u003C/em> notation in data structures describes the worst-case complexity of an algorithm, analyzing how its performance (execution time or memory usage) scales with the size of the input data, denoted by &quot;n&quot;.\u003C/p>\n\u003Ch2 id=\"array\" tabindex=\"-1\">Array\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/Qw8mDu3l0DXPxIrBn89QDSXhqiBxf.png\" alt=\"Learning data structures\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Description\u003C/strong>\nArrays are collections of elements stored in contiguous computer memory; a selected element can be accessed using a numerical index. Each element occupies the same amount of memory, allowing for simple data access at a selected index \u003Cem>(memory start + (index * size of a single element))\u003C/em>.\u003C/p>\n\u003Cp>\u003Cstrong>Advantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Constant time data access regardless of array size\u003C/li>\n\u003Cli>Very fast retrieval of the entire array into the processor cache\u003C/li>\n\u003Cli>Occupies little memory compared to other data structures\u003C/li>\n\u003Cli>Simple and intuitive data indexing\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Disadvantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Static data structure requires allocating new memory blocks when adding more data, and then copying them\u003C/li>\n\u003Cli>Demanding data addition or deletion operations\u003C/li>\n\u003Cli>Memory allocation must be contiguous\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operations\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Adding:\u003C/strong> adding to the end \u003Cem>O(1)\u003C/em>, inserting in the middle \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Deleting:\u003C/strong> deleting from a selected position \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Searching:\u003C/strong> access by index \u003Cem>O(1)\u003C/em>, searching for value \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"linked-list\" tabindex=\"-1\">Linked list\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/gSe0VP7oH9UlkiiHqfCWcMPd5TuLmY.jpg\" alt=\"Learning data structures\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Description\u003C/strong>\nA linked list consists of nodes containing data and a pointer to the next element (sometimes also to the previous one - \u003Cstrong>doubly linked list\u003C/strong>). Elements are stored in various, scattered memory locations, linked only by memory references, creating a sequential data chain without the need to reserve a large memory block.\u003C/p>\n\u003Cp>\u003Cstrong>Advantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Dynamic addition of new elements with efficient memory utilization\u003C/li>\n\u003Cli>Constant time for adding and deleting elements at a known memory location\u003C/li>\n\u003Cli>Does not require pre-allocation of a larger memory area\u003C/li>\n\u003Cli>Easy organization by re-pointing pointers\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Disadvantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Must traverse all preceding elements to find the desired object\u003C/li>\n\u003Cli>Retrieving data into the cache takes a long time due to scattered memory addresses\u003C/li>\n\u003Cli>A single object occupies more memory\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operations\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Adding:\u003C/strong> adding at a known position \u003Cem>O(1)\u003C/em>, adding at another position \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Deleting:\u003C/strong> deleting from a known position \u003Cem>O(1)\u003C/em>, deleting from another position \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Searching:\u003C/strong> searching for a value \u003Cem>O(n)\u003C/em>, accessing a selected position \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"hash-table\" tabindex=\"-1\">Hash table\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/l8dvV8AzxsXng1DSX2oVnWZltEggGy.png\" alt=\"Learning data structures\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Description\u003C/strong>\nThis is a special type of array where the key can be any data type: number, text, object. It uses a hashing function to calculate the index in the array, which allows for very fast access to the value associated with the given key. A good hashing function is very important, as it will help prevent conflicts between keys. Modern implementations (like Python dict or Java HashMap) have very good hashing functions and collision resolution techniques, making the worst-case \u003Cem>O(n)\u003C/em> very rare in practice.\u003C/p>\n\u003Cp>\u003Cstrong>Advantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Constant time for addition, deletion, and value searching operations\u003C/li>\n\u003Cli>Flexible key types allow for complex data relationships\u003C/li>\n\u003Cli>Excellent for implementing cache and databases\u003C/li>\n\u003Cli>Natural mapping of keys and values, no need to use meaningless numbers as keys\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Disadvantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Frequent key collisions can lead to worse performance of operations \u003Cem>(O(1) -&gt; O(n))\u003C/em>\u003C/li>\n\u003Cli>Occupies a lot of memory\u003C/li>\n\u003Cli>Performance depends heavily on the hashing function\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operations\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Adding:\u003C/strong> average case \u003Cem>O(1)\u003C/em>, worst case \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Deleting:\u003C/strong> average case \u003Cem>O(1)\u003C/em>, worst case \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Searching:\u003C/strong> average case \u003Cem>O(1)\u003C/em>, worst case \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"set\" tabindex=\"-1\">Set\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/kqMNkvdKTh2YnsEU3rmGVbNLDdxbGS.png\" alt=\"Learning data structures\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Description\u003C/strong>\nSets are collections that enforce data uniqueness by storing each value at most once. Typically implemented using hash tables or balanced trees, they provide efficient checking for value existence and mathematical operations.\u003C/p>\n\u003Cp>\u003Cstrong>Advantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Automatic data uniqueness guarantee\u003C/li>\n\u003Cli>Very fast checking for value existence\u003C/li>\n\u003Cli>Performing fast mathematical operations (unions, differences, intersections)\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Disadvantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>No indexing or positional access\u003C/li>\n\u003Cli>Occupies more space than regular arrays\u003C/li>\n\u003Cli>Difficult to implement efficiently to ensure uniqueness\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operations\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Adding:\u003C/strong> adding an element for sets implemented on hash tables \u003Cem>O(1)\u003C/em>, and for trees \u003Cem>O(log(n))\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Deleting:\u003C/strong> deleting an element for sets implemented on hash tables \u003Cem>O(1)\u003C/em>, and for trees \u003Cem>O(log(n))\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Searching:\u003C/strong> searching for an element for sets implemented on hash tables \u003Cem>O(1)\u003C/em>, and for trees \u003Cem>O(log(n))\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"stack\" tabindex=\"-1\">Stack\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/buxDqyRgmdvA1hm4Ce93yVHyZpqMVl.png\" alt=\"Learning data structures\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Description\u003C/strong>\nA stack is an abstract data structure implementing the \u003Cstrong>FILO \u003Cem>(First In - Last Out)\u003C/em>\u003C/strong> access style. It is not a separate data structure in itself, like arrays or linked lists, but merely uses various implementations to provide different data access. Elements are added and removed from the same side, known as the &quot;top of the stack&quot;. You can imagine it like stacking books, to get to the bottom, you must first remove all the books from the top.\u003C/p>\n\u003Cp>\u003Cstrong>Advantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Simple and predictable data access\u003C/li>\n\u003Cli>Efficient implementation using arrays\u003C/li>\n\u003Cli>Natural use in recursive algorithms\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Disadvantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Very restrictive data access\u003C/li>\n\u003Cli>To find a value further down, you must first remove the data above it\u003C/li>\n\u003Cli>Each search operation requires creating a new stack\u003C/li>\n\u003Cli>Not suitable for problems requiring random access to data\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operations\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Adding:\u003C/strong> adding to the top \u003Cem>O(1)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Deleting:\u003C/strong> deleting from the top \u003Cem>O(1)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Searching:\u003C/strong> checking the top element \u003Cem>O(1)\u003C/em>, searching for a specific value \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"queue\" tabindex=\"-1\">Queue\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/9ECsGjIHkih5uIn4tGycukH8rwGAVU.png\" alt=\"Learning data structures\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Description\u003C/strong>\nSimilar to a stack, a queue is also an abstract data structure, but it implements the \u003Cstrong>FIFO \u003Cem>(First In - First Out)\u003C/em>\u003C/strong> access style. Elements are added to the back and removed from the front, ensuring fair data processing in the order they were added. An efficient implementation can be achieved using a circular buffer or a doubly linked list.\u003C/p>\n\u003Cp>\u003Cstrong>Advantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Processes data exactly in the order it was added\u003C/li>\n\u003Cli>Ideal for modeling real-world waiting systems\u003C/li>\n\u003Cli>Excellent for breadth-first traversal algorithms and level-order processing\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Disadvantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Requires efficient implementation (circular buffer) to avoid \u003Cem>O(n)\u003C/em> complexity operations when removing from the front of a regular array\u003C/li>\n\u003Cli>More complex than a stack, requiring 2-directional access\u003C/li>\n\u003Cli>Limited access to internal data\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operations\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Adding:\u003C/strong> adding elements from the back \u003Cem>O(1)\u003C/em> with correct implementation\u003C/li>\n\u003Cli>\u003Cstrong>Deleting:\u003C/strong> deleting elements from the front \u003Cem>O(1)\u003C/em> with correct implementation\u003C/li>\n\u003Cli>\u003Cstrong>Searching:\u003C/strong> checking the first element \u003Cem>O(1)\u003C/em>, searching for a specific value \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"trees\" tabindex=\"-1\">Trees\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/83XGx2QXOPTkffeFw5MPwNuNFaDNfY.jpg\" alt=\"Learning data structures\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Description\u003C/strong>\nTrees are hierarchical data structures containing nodes connected by edges, with always only 1 connection from one node to another. A tree always starts with a single element, called the \u003Cstrong>&quot;root&quot;\u003C/strong>; in the case of regular trees, each node can have zero or many child nodes, forming parent-child relationships between nodes. Popular self-balancing implementations include AVL and Red-Black trees.\u003C/p>\n\u003Cp>\u003Cstrong>Advantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Natural representation of hierarchical structures\u003C/li>\n\u003Cli>Efficient searching and sorting in the case of balanced trees\u003C/li>\n\u003Cli>Recursive algorithms naturally map tree structures\u003C/li>\n\u003Cli>Flexible organization supporting various ways of data access\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Disadvantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>More complex implementation than linear data structures\u003C/li>\n\u003Cli>Performance heavily depends on tree balancing\u003C/li>\n\u003Cli>Recursive operations can cause program stack overflow\u003C/li>\n\u003Cli>Requires very careful balancing to maintain optimal operations\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operations\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Adding:\u003C/strong> adding a node in the case of a balanced tree \u003Cem>O(log(n))\u003C/em>, in the worst case \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Deleting:\u003C/strong> deleting a node in the case of a balanced tree \u003Cem>O(log(n))\u003C/em>, in the worst case \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Searching:\u003C/strong> searching for a value in the case of a balanced tree \u003Cem>O(log(n))\u003C/em>, in the worst case \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"graph\" tabindex=\"-1\">Graph\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/JhXKjxXTnDP6s4mkahUWoVgLxAeSVg.png\" alt=\"Learning data structures\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Description\u003C/strong>\nGraphs are collections of vertices connected by edges representing relationships between values. They can be unidirectional or bidirectional, weighted or unweighted, or cyclic, making them the most diverse among data structures. The complexity of operations heavily depends on the representation method - the following refer to representation using an adjacency list.\u003C/p>\n\u003Cp>\u003Cstrong>Advantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>The most diverse data structure for modeling complex relationships\u003C/li>\n\u003Cli>Natural representation of networks, dependencies, and connections\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Disadvantages\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>The most complex data structure to implement and maintain\u003C/li>\n\u003Cli>Algorithms often characterized by high computational complexity\u003C/li>\n\u003Cli>Memory-intensive, especially for dense connections\u003C/li>\n\u003Cli>Detecting and managing cycles increases complexity\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operations\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Adding:\u003C/strong> adding a vertex \u003Cem>O(1)\u003C/em>, adding an edge \u003Cem>O(1)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Deleting:\u003C/strong> deleting a vertex \u003Cem>O(V + E) (where V - number of vertices, E - number of edges)\u003C/em>, deleting an edge \u003Cem>O(E)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Searching:\u003C/strong> searching for a vertex \u003Cem>O(V)\u003C/em>, path between vertices along edges \u003Cem>O(V + E)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"summary\" tabindex=\"-1\">Summary\u003C/h2>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Structure\u003C/th>\n\u003Cth>Description\u003C/th>\n\u003Cth>Applications\u003C/th>\n\u003Cth>Biggest advantage\u003C/th>\n\u003Cth>Biggest disadvantage\u003C/th>\n\u003Cth>Adding\u003C/th>\n\u003Cth>Deleting\u003C/th>\n\u003Cth>Searching\u003C/th>\n\u003C/tr>\n\u003C/thead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Array\u003C/strong>\u003C/td>\n\u003Ctd>Elements in contiguous memory with index access\u003C/td>\n\u003Ctd>Data buffers, mathematical matrices\u003C/td>\n\u003Ctd>Constant access time \u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>Static size, costly insertion\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(n)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Linked list\u003C/strong>\u003C/td>\n\u003Ctd>Nodes connected by pointers\u003C/td>\n\u003Ctd>Stack/queue implementation, text editors\u003C/td>\n\u003Ctd>Dynamic size\u003C/td>\n\u003Ctd>No index access\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(n)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Hash table\u003C/strong>\u003C/td>\n\u003Ctd>Key-value mapping via hash function\u003C/td>\n\u003Ctd>Databases, cache, dictionaries\u003C/td>\n\u003Ctd>Very fast access by key\u003C/td>\n\u003Ctd>Collisions can degrade performance\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Set\u003C/strong>\u003C/td>\n\u003Ctd>Collection of unique elements\u003C/td>\n\u003Ctd>Mathematical operations, deduplication\u003C/td>\n\u003Ctd>Automatic uniqueness\u003C/td>\n\u003Ctd>No positional access\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Stack\u003C/strong>\u003C/td>\n\u003Ctd>LIFO - last in, first out\u003C/td>\n\u003Ctd>Function calls, expression parsing\u003C/td>\n\u003Ctd>Simplicity of implementation\u003C/td>\n\u003Ctd>Very limited access\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(n)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Queue\u003C/strong>\u003C/td>\n\u003Ctd>FIFO - first in, first out\u003C/td>\n\u003Ctd>Queueing systems, BFS algorithms\u003C/td>\n\u003Ctd>Fair processing\u003C/td>\n\u003Ctd>Implementation complexity\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(n)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Tree\u003C/strong>\u003C/td>\n\u003Ctd>Hierarchical structure with a root\u003C/td>\n\u003Ctd>File systems, decision trees\u003C/td>\n\u003Ctd>Efficient searching in the structure\u003C/td>\n\u003Ctd>Requires balancing\u003C/td>\n\u003Ctd>\u003Cem>O(log n)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(log n)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(log n)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Graph\u003C/strong>\u003C/td>\n\u003Ctd>Vertices connected by edges\u003C/td>\n\u003Ctd>Social networks, maps, routing\u003C/td>\n\u003Ctd>Models complex relationships\u003C/td>\n\u003Ctd>Very complex implementation\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(V+E)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(V+E)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003C/tbody>\n\u003C/table>\n","\u003Cp>﻿## Wprowadzenie\u003C/p>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/5BJYLX6YJUQF4wXikNINDSCDZNvpQk.jpg\" alt=\"Nauka struktur danych\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>Notacja \u003Cem>O(n)\u003C/em> w strukturach danych opisuje najgorszy przypadek złożoności algorytmu, analizując w jaki sposób jego wydajność (czas wykonania lub wykorzystanie pamięci) skaluje się wraz z rozmiarem danych wejściowych, oznaczonym przez &quot;n&quot;.\u003C/p>\n\u003Ch2 id=\"tablica\" tabindex=\"-1\">Tablica\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/Qw8mDu3l0DXPxIrBn89QDSXhqiBxf.png\" alt=\"Nauka struktur danych\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Opis\u003C/strong>\nTablice to kolekcje elementów przechowywanych w ciągłej pamięci komputera, do wybranego elementu można dostać się za pomocą numerycznego indeksu. Każdy element zajmuje taką samą ilość pamięci pozwalając na prosty dostęp do danych pod wybranym indeksem \u003Cem>(początek pamięci + (indeks * ilość pamięci pojedynczego elementu))\u003C/em>.\u003C/p>\n\u003Cp>\u003Cstrong>Zalety\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Stały czas dostępu do danych niezależnie od wielkości tablicy\u003C/li>\n\u003Cli>Bardzo szybkie pobieranie całej tablicy do pamięci podręcznej procesora\u003C/li>\n\u003Cli>Zajmuje mało miejsca w pamięci w porównaniu z innymi strukturami danych\u003C/li>\n\u003Cli>Proste i intuicyjne indeksowanie danych\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Wady\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Statyczna struktura danych wymaga alokowania nowych bloków pamięci w przypadku dodawania większej ilości danych, a następnie ich kopiowania\u003C/li>\n\u003Cli>Wymagające operacje dodawania lub usuwania danych\u003C/li>\n\u003Cli>Alokacja pamięci musi być ciągła\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operacje\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Dodawanie:\u003C/strong> dodawanie na koniec \u003Cem>O(1)\u003C/em>, wstawianie w środek \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Usuwanie:\u003C/strong> usuwanie z wybranej pozycji \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Przeszukiwanie:\u003C/strong> dostęp przez indeks \u003Cem>O(1)\u003C/em>, szukanie wartości \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"lista-powiazana\" tabindex=\"-1\">Lista powiązana\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/gSe0VP7oH9UlkiiHqfCWcMPd5TuLmY.jpg\" alt=\"Nauka struktur danych\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Opis\u003C/strong>\nLista powiązana składa się z węzłów zawierających dane oraz wskaźnik do następnego elementu (czasami też do poprzedniego - \u003Cstrong>podwójnie powiązana lista\u003C/strong>). Elementy przechowywane są w różnych, rozproszonych miejscach pamięci, powiązane są jedynie poprzez referencje w pamięci tworząc sekwencyjny łańcuch danych bez potrzeby rezerwowania dużego bloku pamięci.\u003C/p>\n\u003Cp>\u003Cstrong>Zalety\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Dynamiczne dodawanie nowych elementów z wydajnym wykorzystaniem pamięci\u003C/li>\n\u003Cli>Stały czas dodawania i usuwania elementów w znanym miejscu w pamięci\u003C/li>\n\u003Cli>Nie wymaga pre-alokacji większego obszaru pamięci\u003C/li>\n\u003Cli>Łatwa organizacja poprzez przestawienie wskaźników\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Wady\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Trzeba przejść przez wszystkie poprzednie elementy, żeby znaleźć szukany obiekt\u003C/li>\n\u003Cli>Pobieranie danych do pamięci podręcznej zajmuje dużo czasu przez rozproszone adresy pamięci\u003C/li>\n\u003Cli>Pojedynczy obiekt zajmuje więcej miejsca w pamięci\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operacje\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Dodawanie:\u003C/strong> dodawanie w znanej pozycji \u003Cem>O(1)\u003C/em>, dodawanie w innej pozycji \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Usuwanie:\u003C/strong> usuwanie ze znanej pozycji \u003Cem>O(1)\u003C/em>, usuwanie z innej pozycji \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Przeszukiwanie:\u003C/strong> szukanie wartości \u003Cem>O(n)\u003C/em>, dostęp do wybranej pozycji \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"tablica-hashujaca\" tabindex=\"-1\">Tablica hashująca\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/l8dvV8AzxsXng1DSX2oVnWZltEggGy.png\" alt=\"Nauka struktur danych\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Opis\u003C/strong>\nTo specjalny rodzaj tablicy, gdzie kluczem może być dowolny typ danych: liczba, tekst, obiekt. Wykorzystuje funkcję hashującą do obliczania indeksu w tablicy co pozwala na bardzo szybki dostęp do wartości pod podanym kluczem. Bardzo ważna jest dobra funkcja hashująca, gdyż to ona pozwoli zapobiec konfliktom między kluczami. Nowoczesne implementacje (jak Python dict czy Java HashMap) mają bardzo dobre funkcje hashujące i techniki rozwiązywania kolizji, dzięki czemu najgorszy przypadek \u003Cem>O(n)\u003C/em> jest w praktyce bardzo rzadki.\u003C/p>\n\u003Cp>\u003Cstrong>Zalety\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Stały czas wykonywanych operacji dodawania, usuwania i szukania wartości\u003C/li>\n\u003Cli>Elastyczne typy kluczy pozwalają na złożoną zależność między danymi\u003C/li>\n\u003Cli>Świetne do implementacji pamięci podręcznej i baz danych\u003C/li>\n\u003Cli>Naturalne mapowanie kluczy i wartości, nie trzeba wykorzystywać nic nie mówiących liczb jako kluczy\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Wady\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Częste kolizje kluczy mogą doprowadzić do gorszej wydajności operacji \u003Cem>(O(1) -&gt; O(n))\u003C/em>\u003C/li>\n\u003Cli>Zajmuje dużo miejsca w pamięci\u003C/li>\n\u003Cli>Wydajność zależy w bardzo dużej mierze od funkcji hashującej\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operacje\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Dodawanie:\u003C/strong> przeciętny przypadek \u003Cem>O(1)\u003C/em>, najgorszy przypadek \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Usuwanie:\u003C/strong> przeciętny przypadek \u003Cem>O(1)\u003C/em>, najgorszy przypadek \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Przeszukiwanie:\u003C/strong> przeciętny przypadek \u003Cem>O(1)\u003C/em>, najgorszy przypadek \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"zestaw\" tabindex=\"-1\">Zestaw\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/kqMNkvdKTh2YnsEU3rmGVbNLDdxbGS.png\" alt=\"Nauka struktur danych\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Opis\u003C/strong>\nZestawy to kolekcje, które wymuszają unikalność danych przechowując każdą wartość maksymalnie raz. Typowo implementowane przy pomocy tablic hashujących lub zbalansowanych drzew zapewniając wydajne sprawdzanie istnienia wartości i operacje matematyczne.\u003C/p>\n\u003Cp>\u003Cstrong>Zalety\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Automatyczne zapewnianie unikalności danych\u003C/li>\n\u003Cli>Bardzo szybkie sprawdzanie istnienia wartości\u003C/li>\n\u003Cli>Wykonywanie szybkich operacji matematycznych (unie, różnice, krzyżowanie)\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Wady\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Brak indeksowania oraz dostępu pozycyjnego\u003C/li>\n\u003Cli>Zajmuje więcej miejsca niż zwykłe tablice\u003C/li>\n\u003Cli>Trudne w wydajnej implementacji zapewniającej unikalność\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operacje\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Dodawanie:\u003C/strong> dodawanie elementu dla zestawów zaimplementowanych na tablicach hashujących \u003Cem>O(1)\u003C/em>, a dla drzew \u003Cem>O(log(n))\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Usuwanie:\u003C/strong> usuwanie elementu dla zestawów zaimplementowanych na tablicach hashujących \u003Cem>O(1)\u003C/em>, a dla drzew \u003Cem>O(log(n))\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Przeszukiwanie:\u003C/strong> szukanie elementu dla zestawów zaimplementowanych na tablicach hashujących \u003Cem>O(1)\u003C/em>, a dla drzew \u003Cem>O(log(n))\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"stos\" tabindex=\"-1\">Stos\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/buxDqyRgmdvA1hm4Ce93yVHyZpqMVl.png\" alt=\"Nauka struktur danych\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Opis\u003C/strong>\nStos to abstrakcyjna struktura danych implementująca styl dostępu \u003Cstrong>FILO \u003Cem>(First In - Last Out)\u003C/em>\u003C/strong>. Sam w sobie nie jest oddzielną strukturą danych, tak jak tablice czy lista powiązana, a jedynie wykorzystuje różne implementacje zapewniając inny dostęp do danych. Elementy są dodawane i usuwane z tej samej strony, tak zwanej &quot;góry stosu&quot;. Można sobie wyobrazić jak ustawianie książek na stosie, żeby dostać się na dół, trzeba najpierw usunąć wszystkie z góry.\u003C/p>\n\u003Cp>\u003Cstrong>Zalety\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Prosty i przewidywalny dostęp do danych\u003C/li>\n\u003Cli>Wydajna implementacja wykorzystując tablice\u003C/li>\n\u003Cli>Naturalne wykorzystanie w algorytmach rekurencyjnych\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Wady\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Bardzo restrykcyjny dostęp do danych\u003C/li>\n\u003Cli>Żeby znaleźć wartość niżej, trzeba najpierw usunąć dane wyżej\u003C/li>\n\u003Cli>Każda operacja przeszukiwania wymaga tworzenie nowego stosu\u003C/li>\n\u003Cli>Nie nadaje się w problemach wymagających losowego dostępu do danych\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operacje\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Dodawanie:\u003C/strong> dodawanie na szczyt \u003Cem>O(1)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Usuwanie:\u003C/strong> usuwanie ze szczytu \u003Cem>O(1)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Przeszukiwanie:\u003C/strong> sprawdzanie górnego elementu \u003Cem>O(1)\u003C/em>, szukanie poszczególnej wartości \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"kolejka\" tabindex=\"-1\">Kolejka\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/9ECsGjIHkih5uIn4tGycukH8rwGAVU.png\" alt=\"Nauka struktur danych\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Opis\u003C/strong>\nPodobnie do stosu, kolejka to też abstrakcyjna struktura danych, ale implementuje styl dostępu \u003Cstrong>FIFO \u003Cem>(First In - First Out)\u003C/em>\u003C/strong>. Elementy dodawane są na tył, a usuwane od przodu, co zapewnia sprawiedliwe przetwarzanie danych w kolejności w jakiej je dodaliśmy. Wydajną implementację można uzyskać wykorzystując circular buffer lub podwójnie powiązaną listę.\u003C/p>\n\u003Cp>\u003Cstrong>Zalety\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Przetwarzanie danych dokładnie w kolejności w jakiej je dodaliśmy\u003C/li>\n\u003Cli>Idealny do modelowania rzeczywistych systemów oczekiwania\u003C/li>\n\u003Cli>Doskonały do algorytmów przechodzenia wszerz i przetwarzania poziomowego\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Wady\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Wymaga wydajnego zaimplementowania (circular buffer), aby uniknąć operacji o złożoności \u003Cem>O(n)\u003C/em> przy usuwaniu z przodu zwykłej tablicy\u003C/li>\n\u003Cli>Bardziej złożony niż stos, wymagający 2 kierunkowego dostępu\u003C/li>\n\u003Cli>Limitowany dostęp do danych wewnątrz\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operacje\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Dodawanie:\u003C/strong> dodawanie elementów od tyłu \u003Cem>O(1)\u003C/em> z poprawną implementacją\u003C/li>\n\u003Cli>\u003Cstrong>Usuwanie:\u003C/strong> usuwanie elementów od przodu \u003Cem>O(1)\u003C/em> z poprawną implementacją\u003C/li>\n\u003Cli>\u003Cstrong>Przeszukiwanie:\u003C/strong> sprawdzanie pierwszego elementu \u003Cem>O(1)\u003C/em>, szukanie poszczególnej wartości \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"drzewa\" tabindex=\"-1\">Drzewa\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/83XGx2QXOPTkffeFw5MPwNuNFaDNfY.jpg\" alt=\"Nauka struktur danych\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Opis\u003C/strong>\nDrzewa to hierarchiczna struktura danych zawierająca węzły połączone krawędziami, z jednego węzła do drugiego zawsze jest tylko 1 połączenie. Drzewo zawsze zaczyna się od jednego elementu, tak zwanego \u003Cstrong>&quot;korzenia&quot;\u003C/strong>, w przypadku zwykłych drzew każdy węzęł może posiadać zero lub wiele potomnych węzłów tworząc relacje rodzic-dziecko pomiędzy węzłami. Popularne samobalansujące się implementacje to drzewa AVL i Red-Black.\u003C/p>\n\u003Cp>\u003Cstrong>Zalety\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Naturalna reprezentacja hierarchicznych struktur\u003C/li>\n\u003Cli>Wydajne przeszukiwanie oraz sortowanie w przypadku zbalansowanych drzew\u003C/li>\n\u003Cli>Algorytmy rekurencyjne naturalnie mapują struktury drzew\u003C/li>\n\u003Cli>Elastyczna organizacja wspierająca różne sposoby dostępu do danych\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Wady\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Bardziej złożona implementacja niż liniowe struktury danych\u003C/li>\n\u003Cli>Wydajność bardzo zależy od zbalansowania drzewa\u003C/li>\n\u003Cli>Rekurencyjne operacje może powodować przepełnienie stosu programu\u003C/li>\n\u003Cli>Wymaga bardzo uważnego balansu, żeby utrzymać optymalne operacje\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operacje\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Dodawanie:\u003C/strong> dodawanie węzła w przypadku zbalansowanego drzewa \u003Cem>O(log(n))\u003C/em>, w najgorszym przypadku \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Usuwanie:\u003C/strong> usuwanie węzła w przypadku zbalansowanego drzewa \u003Cem>O(log(n))\u003C/em>, w najgorszym przypadku \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Przeszukiwanie:\u003C/strong> szukanie wartości w przypadku zbalansowanego drzewa \u003Cem>O(log(n))\u003C/em>, w najgorszym przypadku \u003Cem>O(n)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"graf\" tabindex=\"-1\">Graf\u003C/h2>\n\u003Cp>\u003Cimg src=\"https://files.jtuta.cloud/public/portfolio/blogs/JhXKjxXTnDP6s4mkahUWoVgLxAeSVg.png\" alt=\"Nauka struktur danych\" loading=\"lazy\" decoding=\"async\">\u003C/p>\n\u003Cp>\u003Cstrong>Opis\u003C/strong>\nGrafy to kolekcje wierzchołków połączonych krawędziami reprezentującymi relacje pomiędzy wartościami. Mogą być jedno lub dwu kierunkowe, ważone - nieważone lub cykliczne, dzięki czemu mogą być najbardziej zróżnicowane wśród struktur danych. Złożoności operacji bardzo zależą od sposobu reprezentacji - poniższe dotyczą reprezentacji za pomocą listy sąsiedztwa.\u003C/p>\n\u003Cp>\u003Cstrong>Zalety\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Najbardziej zróżnicowana struktura danych dla modelowania złożonych relacji\u003C/li>\n\u003Cli>Naturalna reprezentacja sieci, zależności i połączeń\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Wady\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Najbardziej złożona struktura danych do implementacji i utrzymywania\u003C/li>\n\u003Cli>Algorytmy często charakteryzują się dużą złożonością obliczeniową\u003C/li>\n\u003Cli>Intensywne pod względem pamięci, szczególnie w przypadku gęstych połączeń\u003C/li>\n\u003Cli>Wykrywanie cykli i zarządzanie nimi zwiększa złożoność\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Operacje\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Dodawanie:\u003C/strong> dodanie wierzchołka \u003Cem>O(1)\u003C/em>, dodanie krawędzi \u003Cem>O(1)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Usuwanie:\u003C/strong> usuwanie wierzchołka \u003Cem>O(V + E) (gdzie V - liczba wierzchołków, E - liczba krawędzi)\u003C/em>, usuwanie krawędzi \u003Cem>O(E)\u003C/em>\u003C/li>\n\u003Cli>\u003Cstrong>Przeszukiwanie:\u003C/strong> szukanie wierzchołka \u003Cem>O(V)\u003C/em>, droga między wierzchołkami po krawędziach \u003Cem>O(V + E)\u003C/em>\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"podsumowanie\" tabindex=\"-1\">Podsumowanie\u003C/h2>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Struktura\u003C/th>\n\u003Cth>Opis\u003C/th>\n\u003Cth>Zastosowania\u003C/th>\n\u003Cth>Największa zaleta\u003C/th>\n\u003Cth>Największa wada\u003C/th>\n\u003Cth>Dodawanie\u003C/th>\n\u003Cth>Usuwanie\u003C/th>\n\u003Cth>Przeszukiwanie\u003C/th>\n\u003C/tr>\n\u003C/thead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Tablica\u003C/strong>\u003C/td>\n\u003Ctd>Elementy w ciągłej pamięci z dostępem przez indeks\u003C/td>\n\u003Ctd>Bufory danych, macierze matematyczne\u003C/td>\n\u003Ctd>Stały czas dostępu \u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>Statyczny rozmiar, kosztowne wstawianie\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(n)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Lista powiązana\u003C/strong>\u003C/td>\n\u003Ctd>Węzły połączone wskaźnikami\u003C/td>\n\u003Ctd>Implementacja stosów/kolejek, edytory tekstu\u003C/td>\n\u003Ctd>Dynamiczny rozmiar\u003C/td>\n\u003Ctd>Brak dostępu przez indeks\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(n)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Tablica hashująca\u003C/strong>\u003C/td>\n\u003Ctd>Mapowanie klucz-wartość przez funkcję hash\u003C/td>\n\u003Ctd>Bazy danych, cache, słowniki\u003C/td>\n\u003Ctd>Bardzo szybki dostęp przez klucz\u003C/td>\n\u003Ctd>Kolizje mogą pogorszyć wydajność\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Zestaw\u003C/strong>\u003C/td>\n\u003Ctd>Kolekcja unikalnych elementów\u003C/td>\n\u003Ctd>Operacje matematyczne, deduplikacja\u003C/td>\n\u003Ctd>Automatyczna unikalność\u003C/td>\n\u003Ctd>Brak dostępu pozycyjnego\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Stos\u003C/strong>\u003C/td>\n\u003Ctd>LIFO - ostatni wchodzi, pierwszy wychodzi\u003C/td>\n\u003Ctd>Wywołania funkcji, parsowanie wyrażeń\u003C/td>\n\u003Ctd>Prostota implementacji\u003C/td>\n\u003Ctd>Bardzo ograniczony dostęp\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(n)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Kolejka\u003C/strong>\u003C/td>\n\u003Ctd>FIFO - pierwszy wchodzi, pierwszy wychodzi\u003C/td>\n\u003Ctd>Systemy kolejkowania, algorytmy BFS\u003C/td>\n\u003Ctd>Sprawiedliwe przetwarzanie\u003C/td>\n\u003Ctd>Złożoność implementacji\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(n)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Drzewo\u003C/strong>\u003C/td>\n\u003Ctd>Hierarchiczna struktura z korzeniem\u003C/td>\n\u003Ctd>Systemy plików, drzewa decyzyjne\u003C/td>\n\u003Ctd>Wydajne przeszukiwanie w strukturze\u003C/td>\n\u003Ctd>Wymaga balansowania\u003C/td>\n\u003Ctd>\u003Cem>O(log n)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(log n)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(log n)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Graf\u003C/strong>\u003C/td>\n\u003Ctd>Wierzchołki połączone krawędziami\u003C/td>\n\u003Ctd>Sieci społecznościowe, mapy, routing\u003C/td>\n\u003Ctd>Modeluje złożone relacje\u003C/td>\n\u003Ctd>Bardzo złożona implementacja\u003C/td>\n\u003Ctd>\u003Cem>O(1)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(V+E)\u003C/em>\u003C/td>\n\u003Ctd>\u003Cem>O(V+E)\u003C/em>\u003C/td>\n\u003C/tr>\n\u003C/tbody>\n\u003C/table>\n",{"en":25,"pl":61},[26,30,33,37,41,45,49,53,57],{"id":27,"title":28,"mainLevel":29,"subLevel":15},"array","Array",1,{"id":31,"title":32,"mainLevel":19,"subLevel":15},"linked-list","Linked list",{"id":34,"title":35,"mainLevel":36,"subLevel":15},"hash-table","Hash table",3,{"id":38,"title":39,"mainLevel":40,"subLevel":15},"set","Set",4,{"id":42,"title":43,"mainLevel":44,"subLevel":15},"stack","Stack",5,{"id":46,"title":47,"mainLevel":48,"subLevel":15},"queue","Queue",6,{"id":50,"title":51,"mainLevel":52,"subLevel":15},"trees","Trees",7,{"id":54,"title":55,"mainLevel":56,"subLevel":15},"graph","Graph",8,{"id":58,"title":59,"mainLevel":60,"subLevel":15},"summary","Summary",9,[62,65,68,71,74,77,80,83,86],{"id":63,"title":64,"mainLevel":29,"subLevel":15},"tablica","Tablica",{"id":66,"title":67,"mainLevel":19,"subLevel":15},"lista-powiazana","Lista powiązana",{"id":69,"title":70,"mainLevel":36,"subLevel":15},"tablica-hashujaca","Tablica hashująca",{"id":72,"title":73,"mainLevel":40,"subLevel":15},"zestaw","Zestaw",{"id":75,"title":76,"mainLevel":44,"subLevel":15},"stos","Stos",{"id":78,"title":79,"mainLevel":48,"subLevel":15},"kolejka","Kolejka",{"id":81,"title":82,"mainLevel":52,"subLevel":15},"drzewa","Drzewa",{"id":84,"title":85,"mainLevel":56,"subLevel":15},"graf","Graf",{"id":87,"title":88,"mainLevel":60,"subLevel":15},"podsumowanie","Podsumowanie",1781735646106]