<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bedirhan GUL on Medium]]></title>
        <description><![CDATA[Stories by Bedirhan GUL on Medium]]></description>
        <link>https://medium.com/@dev.bedirhangul?source=rss-44d13c724767------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oA1ETxrMfSzZz-c4I4jB2Q.jpeg</url>
            <title>Stories by Bedirhan GUL on Medium</title>
            <link>https://medium.com/@dev.bedirhangul?source=rss-44d13c724767------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 08:31:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dev.bedirhangul/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Efficient and Scalable RPC Services with Go and gRPC A StepbyStep Guide [Unary]]]></title>
            <link>https://medium.com/@dev.bedirhangul/building-efficient-and-scalable-rpc-services-with-go-a-stepbystep-guide-unary-34d774a0f333?source=rss-44d13c724767------2</link>
            <guid isPermaLink="false">https://medium.com/p/34d774a0f333</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[rest]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[rpc]]></category>
            <category><![CDATA[unaries]]></category>
            <dc:creator><![CDATA[Bedirhan GUL]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 15:22:53 GMT</pubDate>
            <atom:updated>2023-09-03T15:24:06.093Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, today we will create RPC services with go and gRPC and then use them on the client side with go. But in the next article we will use React and <a href="https://www.envoyproxy.io/">Envoy Proxy</a> on the client side. Before we start this article, we need to talk about RPC services and the differences between RPC services and rest.</p><h3><strong>Rest</strong></h3><p>REST (Repre­sentational State Transfer) is now the preferred style­ for creating distributed systems in we­b development. Introduce­d by Roy Fielding in 2000, REST has gained popularity due to its simplicity, scalability, and e­ase of integration. However, despite its widespre­ad acceptance, REST does have limitations and disadvantages. This article aims to explore the drawbacks of REST and provide a comparison with RPC (Remote­ Procedure Call) services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BO7XTSfCkz2qJ7J7paVGNw.png" /><figcaption>image 1.1</figcaption></figure><p>REST’s primary limitation lies in its infle­xibility regarding data formats. It heavily relies on JSON (JavaScript Object Notation) for data exchange, but this format struggle­s with certain types of data, such as binary files or large file sizes. Consequently, the efficient transfe­r and handling of diverse data formats become hindered. To overcome this obstacle, alternative approaches like Base64 encoding can be utilized, although they introduce comple­xity and increase overhe­ad for both communicating ends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kagMpUFM1p5SUj3GEEC8LA.png" /><figcaption>image 1.2</figcaption></figure><p>REST is founded on a state­less client-serve­r model. This means that each client request should include all the necessary information for proper understanding and processing. However, this de­sign choice often leads to ve­rbosity in REST APIs, where redundant data is carrie­d within each request. Conse­quently, the payload size and ne­twork traffic increase, resulting in slowe­r and less efficient data transfe­r. In situations with limited bandwidth or large datasets, this drawback can significantly impact performance.</p><p>Another point of consideration is the level of coupling between the client and server in RESTful architectures. REST APIs are resource-centric, meaning that clients need to understand the server’s resource structure beforehand to create and consume resources effectively. Implementing changes to the server’s resource structure often necessitates corresponding changes in the client’s code. This high coupling can impede flexibility and hinder rapid iterations. In contrast, RPC services provide a more decoupled approach where clients can interact with remote methods without explicit knowledge of the server’s underlying resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0_1YLEO3eShqYrQwR6gJQ.png" /></figure><p>When discussing RPC se­rvices, it becomes crucial to highlight the­ distinctions between RPC and REST. REST place­s significant emphasis on utilizing the uniform interface­ of HTTP to manipulate resources, while­ RPC revolves around invoking remote­ methods and procedures. In contrast to REST’s state­lessness, RPC service­s maintain state on the serve­r side, allowing clients to remain state­less. This aspect of RPC service­s enables the e­stablishment of sessions and facilitates sharing conte­xt in specific scenarios.</p><p>Another distinction can be found in the communication protocol. REST relies e­xclusively on HTTP, utilizing different e­ndpoints to represent re­sources and perform operations on the­m. In contrast, RPC offers flexibility in sele­cting communication protocols like HTTP, TCP, or even UDP base­d on the system require­ments. This adaptability empowers de­velopers to optimize communication channe­ls according to their specific use case­s.</p><p>In conclusion, REST has indee­d revolutionized web de­velopment and remains a pivotal compone­nt of many modern applications. However, it is important to acknowledge that REST does have its limitations in terms of data formats, verbosity, coupling, and its statelessne­ss. As a result, develope­rs have started exploring alte­rnative architectures like RPC services. When making archite­ctural decisions, careful evaluation of specific system requirements becomes crucial — whether opting for REST or considering other options. By understanding these drawbacks and variances, deve­lopers can make informed choice­s leading to high-performance, e­fficient, and flexible distribute­d systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfR9csJyIxECXkuhZBTXuA.png" /></figure><p>Because of these disadvantages of rest technology. Big technology companies generally provide communication between microservices with RPC services. Because the unnecessary size of the JSON format is expensive for companies.</p><p>You can read the rest article written by the creator of REST <a href="https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm">here</a>.</p><h3>Now, we can continue to write RPC services with GO and gRPC</h3><p>We can start with a folder structure on the backend side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*8Gp5gSmMvEooBvh1OG0qbg.png" /><figcaption>folder structure</figcaption></figure><p><strong>Client</strong>: The client folder is for client-side operations, but we will not use it for now, we will add the client side towards the end of this article.</p><p><strong>Proto: </strong>The<strong> </strong>proto folder is where our proto files and generated files will be. For example <strong>test.proto</strong></p><p><strong>Server: </strong>There will be server-related codes in the server folder.</p><p>Then I created a new proto file in the proto folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*07gPafN1seEEyQ66helGBw.png" /><figcaption>hello.proto file</figcaption></figure><p>Time for a line-by-line explanation!</p><p><strong>syntax = &quot;proto3&quot;:</strong>This line spe­cifies the version of Protocol Buffe­rs being used in the file­, whether it’s version 2 or ve­rsion 3. It helps to indicate which specific ve­rsion is implemented in this conte­xt.</p><p><strong>message HelloRequest: </strong>The se­ction defines a protobuf message­ called “HelloReque­st.” This message is utilized for carrying data structure­s. In the case of “HelloRe­quest,” it consists of a single field: a string field labeled as “first_name” with the number 1. This particular field represents an individual’s first name. Additionally, you have the option to modify the field number to 9999 if needed, but exe­rcise caution regarding its usage.</p><p>Field numbers should be unique within a message and should be used carefully to maintain backward compatibility when modifying the protocol in the future.</p><p><strong>message HelloResponse: </strong>In this section, anothe­r protobuf message called “He­lloResponse” is define­d. It contains a single field labele­d as number 1, which is a string field named “re­sult.” This particular field represe­nts the response re­sult.</p><p><strong>service HelloService:</strong> The protobuf se­rvice “HelloService­” is defined in this section. Se­rvices are used to re­present specific functions or me­thods that can be accessed by a clie­nt. In the case of “HelloSe­rvice,” there is one­ RPC method called “Hello.” This me­thod requires a single parame­ter called “HelloRe­quest” and returns a response­ of type “HelloResponse­.” Its purpose is to greet some­one using their first name and provide­ a response.</p><p>To summarize, the­ provided protobuf code outlines a straightforward se­rvice named “HelloSe­rvice,” which includes one RPC me­thod called “Hello.” This method re­quires the input of a person’s first name­ and returns a greeting me­ssage as a response. The­ code is structured to gene­rate both Go code and protobuf definitions for facilitating gRPC-base­d communication.</p><h3><strong>Generate code with gRPC!</strong></h3><p>We wrote proto file and services now we can generate service code. Generate command:</p><pre>$ protoc --go_out=. --go_opt=paths=source_relative \<br>    --go-grpc_out=. --go-grpc_opt=paths=source_relative \<br>    helloworld/helloworld.proto</pre><p>If you have more information or you have a problem you can check this <a href="https://grpc.io/docs/languages/go/quickstart/#regenerate-grpc-code">link</a>. This command generate these files:</p><p>1- hello_grpc.pb.go</p><p>2- hello.pb.go</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*NOZ4IcGun1FU-FXYbRrXrQ.png" /><figcaption>generated files</figcaption></figure><h3><strong>Now it’s time for the server-side</strong></h3><p>Create <strong>main.go</strong> file in the server folder. Then write these codes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVvfyHAfn9g7VzHGL5yU0A.png" /><figcaption>main.go file</figcaption></figure><p>In this file, we listen 0.0.0.0:4007 port with <a href="https://www.techtarget.com/searchnetworking/definition/TCP">TCP protocol</a>. Then we create a new grpc server using grpc package. We will write service but we have to talk about RPC life cycle because we will write unary rpc service. Also gRPC has a lot of rpc service types like unary, server streaming, client streaming, and bidirectional streaming.</p><h3><strong>Types of RPC</strong></h3><p>In this section talk about rpc types. We will write in this article unary rpc but you can try other rpc types.</p><p>1- Unary RPC</p><p>2- Server Streaming RPC</p><p>3- Client Streaming RPC</p><p>4- Bidirectional streaming RPC</p><h4>Unary RPC</h4><p>The simplest type of RPC involves a single request and response. When the client initiates the RPC by calling a stub method, the server is notified with the client’s metadata, method name, and deadline (if applicable). The server can respond with its own metadata or wait for the client’s request message. Once the server receives the request, it generates a response with status details and optional metadata. If the response status is OK, the call is completed on the client side. Also, we will write unary rpc in this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ms8_jrs1Gz1ewG18zdsIPw.png" /></figure><h4>Server Streaming RPC</h4><p>A server-streaming Remote Procedure Call (RPC) is akin to a unary RPC, with the exception that the server furnishes a stream of messages in reply to a client’s request. Upon transmitting all messages, the server’s status particulars (status code and optional status message) and optional trailing metadata are dispatched to the client, thereby concluding server-side processing. The client concludes its operation upon receiving all server messages. For example download process, watching video, live streaming (Twitch, youtube live, IG Live)</p><blockquote><strong>!info</strong>: Twitch uses <a href="https://github.com/twitchtv/twirp">twirp</a> on the backend side for services. Google uses <a href="https://github.com/grpc">gRPC</a> and Facebook uses <a href="https://github.com/facebook/fbthrift">fbthirft</a>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L4f8lRa2JYYaTUyfFFcLIA.png" /><figcaption>Server Streaming RPC</figcaption></figure><h4>Client Streaming RPC</h4><p>A client-streaming Remote Procedure Call (RPC) involves the transmission of a message stream from the client to the server, as opposed to a single message in a unary RPC. The server responds with a single message, including status details and optional metadata, usually after receiving all client messages. For example, uploading something, streaming for streamers, recording voice</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*od4ldH2Qa9k-hw5zITK3dQ.png" /><figcaption>Client Streaming RPC</figcaption></figure><h4>Bidirectional streaming RPC</h4><p>The initiation of a bidirectional streaming RPC involves the client invoking the method and the server receiving metadata, method name, and deadline. The server may opt to send its initial metadata or await the client’s message streaming. The processing of client- and server-side streams is application-specific, with independent streams allowing for message reading and writing in any order. For instance, the server can wait for all client messages before sending its own or engage in a “ping-pong” exchange with the client. For example message services, video conferences, and IoT applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PdaQxBDkhzGUsuSD6PvRYg.png" /><figcaption>Bidirectional streaming</figcaption></figure><h3>Create Hello RPC service implementation</h3><p>We wrote server connection code. Now we can continue to write hello rpc service. First of all, we have to add this line on main.go file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2QQitBQalNXBh5xcd00s7w.png" /><figcaption>Hello service</figcaption></figure><pre>pb.RegisterHelloServiceServer(s, &amp;Server{})</pre><p>Now that we have added the Hello service on the server side, we will send the response to the client side if the request requested by the hello service arrives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JOCsYXmYgdN0zZI-4n-amQ.png" /><figcaption>hello.go</figcaption></figure><p>When we request with HelloRequest value this service response is like this: <strong>Hello {Request.FirstName}. L</strong>et’s start our server before moving to the client side. I ran the server file in the bin. It works! 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*_tx4sP4yoD2S1YbWWod_0A.png" /></figure><h3>Client Side 🚧</h3><p>I created the client side with go, but as I said at the beginning of the article, in the next article we will create the client side using React and Envoy Proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1BStoHziZNx7-RSvLZo8mg.png" /></figure><pre> conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))</pre><p>This code e­stablishes a connection (conn) to a gRPC serve­r located at the address give­n by addr. To configure this connection, it uses inse­cure transport credentials. Howe­ver, it’s important to note that in production environme­nts, using insecure transport crede­ntials is not recommended due­ to security risks. We are curre­ntly using this configuration because our app does not curre­ntly support TLS encryption.</p><h4>Now it’s time to send a request🤩</h4><p>Once the­ server is ready on the­ backend, it’s time to send a re­quest. We import the ne­cessary packages, including standard libraries like­ “context” and “log,” as well as the “pb” package­. The “pb” package houses the­ “HelloServiceClie­nt” type, which handles communication with gRPC. You can find this package at “github.com/be­do/grpc/greet/proto.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmeIoFt4L1vclsYowhaa_A.png" /></figure><p>To retrie­ve a response from the­ gRPC service, we se­nd a request and store the­ response in the “re­s” variable. In case of an error, it is logge­d along with any accompanying details.</p><h4>Run Time 🏃🏻</h4><p>First of all, run the server. Everything is okay. Now we can send a request to 0.0.0.0:4007 port.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*u8mw7lfr0qgHS_OI-l9oIQ.png" /></figure><p>That&#39;s it! Now you can try other rpc types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vxBKBwCxtVrEw2TLlnjkHQ.png" /></figure><p>Thanks, for taking the time to read my article. In my piece we’ll explore how React and Envoy proxy can be utilized on the client side. If you’re interested we’ll also delve into Server Streaming RPC. Additionally, feel free to connect with me on Twitter and LinkedIn.</p><p><a href="https://twitter.com/bedirhngl">Twitter</a></p><p><a href="https://www.linkedin.com/in/bedirhan-g%C3%BCl/">LinkedIn</a></p><p>Sources:</p><p><a href="https://aws.amazon.com/compare/the-difference-between-rpc-and-rest/#:~:text=In%20Remote%20Procedure%20Call%20(RPC,on%20a%20specific%20server%20resource.">aws</a> — <a href="https://nordicapis.com/whats-the-difference-between-rpc-and-rest/">nordicapis</a> — <a href="https://www.geeksforgeeks.org/difference-between-rest-api-and-rpc-api/">GeekForGeeks</a> — <a href="https://www.smashingmagazine.com/author/philsturgeon/">Phill Sturgeon</a> — <a href="https://grpc.io/docs/what-is-grpc/introduction/">grpc</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34d774a0f333" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Structures]]></title>
            <link>https://medium.com/@dev.bedirhangul/data-structures-9ed9121912ab?source=rss-44d13c724767------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ed9121912ab</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[computer-engineering]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Bedirhan GUL]]></dc:creator>
            <pubDate>Sun, 30 Apr 2023 08:01:31 GMT</pubDate>
            <atom:updated>2023-05-03T17:16:37.042Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi everyone, I want to talk about data structures. You should learn data structures and algorithms because coding or software engineering really just involve manipulating data and solving problems. In my opinion, it is essential to learn data structures and algorithms, for instance, if you are building web applications, mobile applications, or backend systems. You might need to transform data into a human-readable format or sort products by pricing or date. Similarly, if you are developing services or APIs, you might need to write code that stores and retrieves data from a database, transforms it, and returns it to a client that requests it. The last example is coding interviews.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*snIT_c18Ah9pW1Bhmc4dMw.png" /><figcaption>data structures cover photo</figcaption></figure><h4>First of all, we need to learn these notions</h4><p><strong>Time complexity</strong>: In computer science, time complexity measures the amount of time it takes to run an algorithm as a function of the size of the input. It is used to analyze the efficiency of algorithms and to compare the performance of different algorithms for the same problem. Time complexity is typically expressed using big O notation.</p><p>For example, we may have an algorithm that finds words in a dictionary. However, if this algorithm searches through all the pages to find the word instead of looking at the first letter to streamline the search process, it will take longer to find the word. Therefore, understanding time complexity is important to optimize algorithms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*6KWhdIt71hDfxPUggb9SkA.png" /></figure><p><strong>Best case</strong>: If the word in question is “author”, it will be found on the first page. This is the best case because our algorithm starts the search process from the first page. Average case: This is the situation that we generally expect. Worst case: If the word in question is “zero”, it will be found on the last page.</p><p><strong>Average case</strong>: The situation I generally expect.</p><p><strong>Worst case</strong>: If the word in question is “zero”, it will be found on the last page.</p><p><strong>Space complexity: </strong>Space complexity is a measure of the amount of memory used by an algorithm to solve a problem. It determines the amount of memory needed to store the input, intermediate data, and output. For example, the space complexity of the expression <strong>‘console.log(“hello world”)’</strong> is quite low because the expression outputs only a string, which occupies very little memory space. The space complexity of a JavaScript application can vary depending on its usage. However, the space complexity of this sample code can be expressed as O(1) because the code requires a fixed amount of memory space to run, and this amount is not dependent on the size of the application or the input.</p><p><strong>Memory: </strong>Memory is used by a computer’s operating system, hardware, and software. For instance, data is stored in memory as bytes. Additionally, variables and instances of structures and classes are also stored in memory. Memories have many pointers. They are used to access data stored in memory. Pointers can be used to perform a wide variety of operations on data in memory, such as reading, modifying, or deleting data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*m9b7VEdr7XpBFuHDXOlV-A.png" /></figure><p><strong>Byte</strong>: A byte has eight bits. For example, 00000101 is a byte. A single byte can represent up to 256 data values (²⁸). For more information. For more information looks at <a href="https://www.engineeringtoolbox.com/binary-decimal-hexadecimal-ascii-converter-d_1914.html">this link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*Jw6ljtdxbglsoCZ_DQN0bQ.png" /><figcaption>You can see the calculation binary number convert to a decimal number</figcaption></figure><p><strong>Bit</strong>: A “bit” (short for binary digit) is the smallest unit of data used in computers and other digital devices. A bit has two possible values (typically 0 or 1), which correspond to the states of electronic or magnetic signals.</p><p><strong>Fixed width integer</strong>: Fixed-width integers are integral types with a fixed number of bits. For example:</p><p>32-bit integer has 4 bytes 32-bit like that: 00000000 00000000 00000000 00000001</p><p>64-bit integer has 8 bytes 64-bit like that: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00001010</p><h4>Ohh, is finally over. Now we can continue with Arrays :)</h4><h3>Array</h3><p>Arrays are one of the most fundamental, perhaps the most fundamental data structures of all. If you have development experience, you have likely declared an array, manipulated an array, or perhaps a slice in Go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*xzoxhP-8qd0rvJ8gcYYprQ.png" /><figcaption>The numbers 1, 2, and 3 are of the ‘int64’ data type. If the numbers were of the ‘int32’ data type, they would be 4 bytes long.</figcaption></figure><p>A language-independent array is stored in memory as a sequence of consecutive memory blocks. Each element has a memory address based on its position in the array, and these addresses are arranged consecutively in the memory of the device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*ttnaMXC2LpWWKpuUkr2YHw.png" /><figcaption>a pointer has 8byte because our computer os 64bit</figcaption></figure><p>If we want to access an element in an array, we would type something like this: numbers[0]. This means we are accessing the memory address of that element.</p><p>There are two types of arrays. The first array type is a static array that allocates memory at compile-time and has a fixed size. We cannot alter the static array. For example, in Go, we can declare a static array like this:</p><pre>s := make([]string, 3)<br>fmt.Println(&quot;emp:&quot;, s)</pre><pre>---&gt;emp: [ ]<br>// but we reserved three pointers</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*pKRQOXS9QvvdVQOLQ5fQXw.png" /></figure><p>In a dynamic array, you can add as many items as you want without needing to assign an array size ahead of time. Just like static arrays, elements in the array are stored right next to each other in memory, making efficient use of caches. If you want to add a new element at the end of the dynamic array, this process takes O(1) time. If you don’t know what big O is, you can read <a href="https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/">this</a> article.</p><h3>Linked list</h3><p>A linked list is similar to an array, but not identical. In a linked list, nodes are stored in memory along with the address of the next node. Therefore, each node is aware of the next node’s address. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*41vaH3jXfDlY17cBgxzHmA.png" /></figure><p>In this situation, this structure provides flexibility in sorting nodes in memory, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YTZtwrZ4cRNkwMSU_3-kTQ.png" /></figure><p>Why use a linked list? First of all, a linked list is dynamic, which makes adding and deleting nodes easy. However, each node in a linked list has two pointers, which means that it stores more data than a simple array. If your data is large, the linked list will take up more storage space than a simple array with the same number of elements.</p><p>There are many types of linked lists, but it’s important to learn about the doubly linked list. In a doubly linked list, each node has a pointer to both the next node and the previous node. This requires extra space to store each node, but it allows for more efficient traversal in both directions. The doubly linked list looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F48xVdPKfK_o9u5OEkk1Pw.png" /></figure><p>In a doubly linked list, it is easy to get the node. Now, let’s talk about a circular list. In a circular list, there is no null at the end. Instead, the first node and the last node are connected to each other, forming a circle. It looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bhi4Q3-VCxPCu8B1w6tjoQ.png" /></figure><p>This means that you can return to the beginning of the list while traversing it at its end.</p><h3>Hash table</h3><p>The hash table is usually used to access data quickly. In a hash table, data is stored in an array. To use a hash table, you need keys and a hash function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*qUHyzqkrHFFGljgFnk7DPA.png" /><figcaption>example for hash tables</figcaption></figure><p><strong>Key</strong>: The key can be a string or integer. It doesn’t matter. It is the technique that determines an index or location for the storage of an item in a data structure.</p><p><strong>Hash Function</strong>: Hash functions evenly distribute the data. These functions assign the index number for each key.</p><p><strong>Hash Table</strong>: A hash table is a data structure that utilizes a special function called a hash function to map keys to their corresponding values.</p><p>If your hash function does not evenly distribute the data, you can see collision problems in the hash tables. For example, Anderson and Lisa may end up at the same position like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sGN10wEsOPkVwYMmOqsGEw.png" /><figcaption>collision problem</figcaption></figure><p>You can solve this problem using hash algorithms. Common hash algorithms include CRC-32, MD-5, and SHA-1. If you wanna more information on collision problems you can visit <a href="https://en.wikipedia.org/wiki/Hash_collision">this link</a>.</p><h3>Stacks and Queues</h3><p>They are not too hard to implement. Also, stacks and queues are very easy to understand. Let me explain with real-life examples. Stacks follow the LIFO (Last In First Out) principle. Each added data is placed at the top of the stack in a stack structure. This structure is usually used for undo features, recursive functions, infix-to-postfix processes, and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*do3XCoITuZV0cqGbyaMnVw.png" /><figcaption>Note: Don’t be like Mike, always align horizontal the boxes on the table</figcaption></figure><p>First of all, Mike needs to take box_1. Then box_2 and finally box_3.</p><p>But the queue is almost the exact opposite of the stack structure. Because the queue follows the FIFO (First In First Out) principle. If you want to add data to the queue, you can add it at the end of the queue. Also, when data is removed from the queue, the data at the beginning of the queue is removed. This structure is usually used in most operating systems, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IS8meg4pdRPp5llJxTUDXQ.png" /><figcaption>you can see the FIFO principle in the picture</figcaption></figure><h3>Strings</h3><p>Strings are stored in an array structure. Therefore, strings can be concatenated with other strings to create a new string value. You can also modify individual characters in a string and search for substrings. For example, if the string value is “Bedo”, you can modify it to “bedoTest”. But how is a string stored in memory?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0vO4PC69GTZXd9Xgmrr8vg.png" /></figure><p>We said, “Strings are stored in an array structure.” Therefore, we can access the characters by using index numbers, like this in Go:</p><pre>var name string = &quot;bedirhan&quot;</pre><pre>func main() {<br> fmt.Printf(“%c”, name[1])<br> fmt.Pirntf(name[0])<br>}</pre><pre>//output : e<br>//output : 98 -&gt; ASCII value of the &quot;b&quot;</pre><p>And don’t forget: Some programming languages use <strong>mutable strings</strong>, which means that you can change the string value. For example, Python, C++, Ruby, PHP, and JavaScript support mutable strings. However, languages like Go, Java, Kotlin, and Swift use <strong>immutable string structures</strong>, which means that you cannot change the string value once it is created.</p><h3>Graphs</h3><p>Graphs are an important data structure. They are commonly used in coding interviews and software development to represent connections between data. For example, in computer science and related fields such as network analysis, social network analysis, and data mining, graph structures are frequently utilized. A set of vertices or values can be connected to each other through links called edges. It looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*69XD8cA_bxV2z2HSg3wLaA.png" /></figure><p>let’s continue with the types of graphs. The first type is the cycle graph.</p><blockquote>cycle graph</blockquote><p>In the cycle graph, each vertex (or node) has two edges. Additionally, this graph appears as a cycle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*qMHyOlOsZhhw0AEvk-_Hig.png" /><figcaption>for example cycle graph</figcaption></figure><blockquote>directed graph</blockquote><p>A graph with directed edges that forms a directed acyclic graph (DAG). Looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*qP9KFx4C9dbuiMGuxPmmLQ.png" /><figcaption>directed graph</figcaption></figure><p>but if you don’t have any directed edges, it means this graph name is an undirected graph.</p><blockquote>connected graph</blockquote><p>It should have at least one vertices and there is at least one edge between any two vertices in the graph. Like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*MDqETso_NiNi4wGybOS6yQ.png" /><figcaption>connected graph</figcaption></figure><p>now we will learn some terms about graphs.</p><p><strong>Strongly connected: </strong>A directed graph is considered ‘strongly connected’ if there is a bidirectional path between any two vertices. This is what the term refers to. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*ZmJCyHbQDe4pxsqDJ9ZVHQ.png" /><figcaption>strongly graph examples</figcaption></figure><p><strong>Weakly connected graph: </strong>It has unidirectional and bidirectional edges. So, what are the differences between strongly connected graphs and weakly connected graphs? In a strongly connected graph, all edges are bidirectional, meaning every vertex in the graph can reach every other vertex. On the other hand, in a weakly connected graph, there may be unidirectional edges, and while there exists a path between any two vertices, it may not be bidirectional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*blza5RJR0fAyfxE9typHmg.png" /><figcaption>weakly graph example</figcaption></figure><h3>Tree</h3><p>A tree is similar to a graph and is a hierarchical data structure that can be used to represent and organize data. All nodes in a tree are connected by edges, like a graph. Additionally, all trees should have a root, subtree, and leaf nodes. It looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*ip8RW4-RsZs_e_kdKMwWEA.png" /></figure><p>You don’t do these things in a tree data structure:</p><ul><li>Firstly, child nodes cannot have two parents. If they did, it would result in a directed graph rather than a tree.</li><li>Every tree must have one root node.</li><li>In a standard tree data structure, a child node does not have direct access to its parent node. However, the parent node can have a reference or pointer to its child nodes.</li></ul><p>let’s continue with types of tree</p><blockquote><strong>Binary tree</strong></blockquote><p>In a binary tree, each node has at most two children.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*CSYQHEJU_Pvk7ARtE59WBw.png" /><figcaption>binary tree example</figcaption></figure><blockquote>K-ary Tree</blockquote><p>A k-ary tree is a tree data structure in which each node has at most k children. The value of k is usually 2, but it can be any positive integer. For example, a 2-ary tree (binary tree) has at most 2 children, while a 3-ary tree (ternary tree) can have at most 3 children</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f9ozuJjCrd4cdnO2ZTMZWg.png" /></figure><blockquote>Perfectly Binary Tree</blockquote><p>In a full binary tree, all interior nodes have two children and all leaves are at the same depth or level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*0PBcPXdzvVlT7O9mWM66TA.png" /><figcaption>perfectly binary tree</figcaption></figure><blockquote>Balanced Tree</blockquote><p>A balanced binary tree is a binary tree structure in which the difference in height between the two sub-trees of each node is at most one. In other words, the height difference between the left and right sub-trees can be at most one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gjLP0saLkrsUcfKyVFZogQ.png" /><figcaption>balanced tree and unbalanced tree</figcaption></figure><blockquote>Last type is Full binary tree</blockquote><p>Every node in a complete binary tree has either two children or zero children. It looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*k6E5kUHgR29bz8cZFsGbrg.png" /><figcaption>full binary tree</figcaption></figure><p>We’ve come to the end of the article. Thank you so much for reading it. If you’d like to follow me on Twitter, you can do so here. Have a nice day! :)</p><p><a href="https://twitter.com/bedirhngl">Twitter</a></p><p><a href="https://github.com/bedirhangull">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ed9121912ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[react-native-flash-swiper installation [React Native]]]></title>
            <link>https://medium.com/@dev.bedirhangul/react-native-flash-swiper-installation-react-native-f9fdb4388625?source=rss-44d13c724767------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9fdb4388625</guid>
            <category><![CDATA[swiper]]></category>
            <category><![CDATA[npm-package]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Bedirhan GUL]]></dc:creator>
            <pubDate>Sun, 02 Oct 2022 13:54:51 GMT</pubDate>
            <atom:updated>2023-07-08T10:34:25.298Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, today I am published react-native-flash-swiper. You can use it.</p><p><a href="https://github.com/bedirhangull/react-native-flash-swiper">https://github.com/bedirhangull/react-native-flash-swiper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/231/1*Y80SgFG6at0qm0FxguX3MA.gif" /></figure><p>What are these different features?</p><ul><li>You can swipe images and components</li><li>It is easy and fast to use</li><li>When you use it, you will not experience any shifts in the screen</li></ul><p>Other components use the number and dot to detect the width of the screen whereas, I use the component width. The image below shows another swiper, and as you can see when added margin and paddings there are shifts in the images. Let’s imagine this screen is 400px, and the margin is. 20px. Then are swiper needs to be downsized by 40 px. The reason for this shift is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*u0WbC54ghKlw-99XQ_rNFQ.png" /></figure><pre> Lets say width of the component 400px = x</pre><pre>Screen width = y</pre><pre>Swiper width = z</pre><pre>First screen : ( x / y ) = z</pre><pre>Second screen : ( x + x ) / y = z</pre><pre>We can make x + x because the first page continues</pre><pre>Third screen ( x + x + x ) / y = z, and it goes like this.</pre><p>That’s how the component knows on which page it is. Whereas in my component it works like this:</p><pre>Margin or padding value = b</pre><pre>First screen ( x — 2 * b) / z = 1</pre><pre>Second screen ( x — 2 * b) / z = 2</pre><p>Since we calculate the width correctly, my swiper doesn’t have any shifts. I hope it helps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*jC4KdGd4TmXv281Mlj4fwg.png" /><figcaption>react-native-flash-swiper</figcaption></figure><p><strong>My social accounts:</strong></p><p><a href="https://www.linkedin.com/in/bedirhan-g%C3%BCl/">Linkedin</a> : <a href="https://www.linkedin.com/in/bedirhan-g%C3%BCl/">https://www.linkedin.com/in/bedirhan-g%C3%BCl/</a></p><p>Twitter: <a href="https://twitter.com/bedirhngl">https://twitter.com/bedirhngl</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9fdb4388625" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>