<?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 Menhaj Sharaf on Medium]]></title>
        <description><![CDATA[Stories by Menhaj Sharaf on Medium]]></description>
        <link>https://medium.com/@menhajharaf?source=rss-693e521cb47b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Menhaj Sharaf on Medium</title>
            <link>https://medium.com/@menhajharaf?source=rss-693e521cb47b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 01:36:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@menhajharaf/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[Coding Bootcamp: A Journey to Becoming a Web Developer or Landing a Tech Job]]></title>
            <link>https://menhajharaf.medium.com/coding-bootcamp-a-journey-to-becoming-a-web-developer-or-land-a-tech-job-ffce70ffd07a?source=rss-693e521cb47b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffce70ffd07a</guid>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[codingbootcamp]]></category>
            <category><![CDATA[career-advice]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Menhaj Sharaf]]></dc:creator>
            <pubDate>Sat, 26 Mar 2022 04:29:36 GMT</pubDate>
            <atom:updated>2022-03-27T01:49:03.443Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1wZXIWuiJoDONQ6c3MTWuw.jpeg" /><figcaption>Photo by AltumCode. unsplash.com/photos/PNbDkQ2DDgM</figcaption></figure><p>Depending on your preparation, attending a coding bootcamp can either help you land a job as a web developer or begin your coding journey which may take from 6 months to 3 years. If you don’t give up and continuously improve your skills, you will eventually succeed in securing a job as a web developer. However, if you can’t build a basic full CRUD (Create, Read, Update, Delete) application, you may not be ready to attend a coding bootcamp yet. As a result, you may not benefit from a coding bootcamp as much as those who can. Furthermore, attending a coding bootcamp for some learners is a stressful decision to make. Questions such as:</p><ul><li>Will I be able to benefit from investing into a coding bootcamp?</li><li>Are 15 weeks enough to become a full stack web developer?</li><li>Am I ready to be a full-time student without any income?</li><li>What if I don’t get hired after graduation?</li><li>Who is right about the coding bootcamps, those who say coding bootcamps are worthless or those who say coding bootcamps are the best opportunity to change your career?</li></ul><p>These are a few of the questions that some learners face while thinking about attending a coding bootcamp. In addition, availability of free content such as from Udemy.com or Udacity.com complicates the situation further. Why attend a coding bootcamp when you can simply pay $10 for an online course?</p><p>This article is meant to provide some basic information on the pros and cons of attending coding bootcamps. Google searches on success of coding bootcamps often reveal mixed results: some claim the expense isn’t worth it, while some successful bootcamp graduates went on to jobs at Microsoft, LinkedIn, Google, Facebook, Uber, Lyft etc. Keep in mind, attending a bootcamp can either become the starting point of your web development journey or finding a job in the tech industry. Depending on your situation, if you don’t give up, you will eventually find a job as a developer. If you have already decided in enrolling in a coding bootcamp and can’t answer the following questions, you may reevaluate your decision:</p><ul><li><a href="https://www.educative.io/blog/object-oriented-programming">What is Object Oriented Programming (OOP)?</a></li><li><a href="https://www.geeksforgeeks.org/difference-between-class-and-object/">What is the difference between a class and an object?</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions">What is a function?</a><a href="https://www.geeksforgeeks.org/pure-functions-in-javascript/#:~:text=Pure%20Function%20is%20a%20function,depends%20on%20its%20input%20arguments."> What is a pure function?</a></li><li><a href="https://www.codecademy.com/learn/game-dev-learn-javascript-higher-order-functions-and-iterators/modules/game-dev-learn-javascript-iterators/cheatsheet#:~:text=In%20Javascript%2C%20functions%20can%20be,and%2For%20returns%20a%20function.">What are high order functions?</a></li><li><a href="https://www.codecademy.com/article/what-is-rest">What is REST and what are HTTP verbs?</a></li><li><a href="https://www.codecademy.com/article/what-is-crud">Can you build a basic full CRUD web application?</a></li><li><a href="https://academind.com/tutorials/frontend-vs-backend#:~:text=Frontend%20and%20backend%20communicate%20with,store%20it%20in%20some%20database.">How do frontend and backend communicate in web applications?</a></li><li><a href="https://en.wikipedia.org/wiki/Control_flow#:~:text=Within%20an%20imperative%20programming%20language,or%20more%20paths%20to%20follow.">What is a control flow?</a></li><li><a href="https://techvidvan.com/tutorials/java-loops/#:~:text=In%20Java%2C%20there%20are%20three,generally%20known%20as%20loop%20control.">What are iterations such as for-loop, while-loop, do while-loop?</a></li><li><a href="https://www.w3schools.com/java/java_data_types.asp">Can you describe basic data types: integers, string, characters, and objects?</a></li></ul><p>These are the basic concepts which are recommended to know prior to enrolling in a coding bootcamp. If you attend a coding bootcamp and even if you do their pre-bootcamp material, the lack of fundamental knowledge will slow your learning track.</p><p>In addition to the bootcamp, there are other choices available too. The other common ways to become a programmer or a web developer are attending a four-year university or a two-year community college and self-study. Neither of these options is easy. In fact, there is no easy path for any new skill to acquire. Most of us learn new skills by doing the hard work and spending the time required to develop the skill. Whether it is a physical or theoretical work, most of us must practice and spend time in order to master it. While the coding bootcamps are a shortcut to becoming a web developer, some fail to achieve their goal due to lack of preparedness or wrong expectations. Those who do the pre-work such as learning the programming fundamentals and studying the basics of computer science usually succeed in a coding bootcamp and ultimately in getting a job as a web developer right after graduation. However, those who join the bootcamp without any preparation or coding knowledge face lots of challenges which may mean it takes longer for them to get hired. Since 2018, those around me who have succeeded in their career changes from a non-tech industry to tech have one thing in common: consistency/persistence. Those who never give up hope of achieving their goal eventually achieve their dreams.</p><p>Before committing to a coding bootcamp, collecting the following skills and knowledge will likely increase your chances of success:</p><ul><li>You should be able to build a static website using HTML, CSS and JavaScript</li><li>A good understanding of DOM, getElementById, tags, and functions are necessary.</li><li>Basics of computer science.</li><li>Fundamentals of programming, especially the language which the bootcamp teaches.</li><li>A basic understanding of Object-Oriented Programming.</li></ul><p>Why should you know these? If you don’t know these fundamentals, you will struggle through the bootcamp. When your instructor speaks about the higher order function, you will be confused. As a result, you will be spending lots of time on googling to learn the basics rather than the material. Eventually, you will be behind and will try to catch up with the rest of the class. It doesn’t mean you may not succeed, but you will face lots of challenges due to lack of preparedness. At this stage you may question yourself if you had made the right decision on attending the coding bootcamp.</p><p>On the other hand, you can visit and learn from www.freecodecamp.com’s JavaScript curriculum and responsive web design, basics of databases and build a basic CRUD (Create, Read, Update, Delete) application, prior to attending a coding bootcamp. Depending on your time constraints and budget, the following available choices can also be considered:</p><ul><li>Self-taught.</li><li>4-year college, computer science degree.</li><li>2-year of community college plus either self-study or attend a coding bootcamp.</li></ul><p>Among these, self-taught is the most challenging due to the lack of a predefined curriculum. Some people prefer to follow a pre-prepared guideline. If you think you can manage your time and design a curriculum based on google search or available articles online, this may be the cheapest route for becoming a web developer. As of 2022, becoming a self-taught developer may not be as challenging as the last decade. Online educational platforms such as<a href="http://www.freecodecamp.org/"> www.freecodecamp.org</a>,<a href="https://www.edx.org/"> www.edx.org</a> ,<a href="http://www.coursera.com/"> www.coursera.com</a>,<a href="http://www.udemy.com/"> www.udemy.com</a>,<a href="http://www.linkedin.com/learning"> www.linkedin.com/learning</a>, and<a href="http://www.udacity.com/"> www.udacity.com</a> have full stack course curriculums that you can follow and learn easily. While you may need to buy some computer science books to empower your understanding of the fundamentals, the challenge of the self-taught path to becoming a programmer is maintaining the discipline required to stick to your plan. For this reason, it’s not advisable to switch programming languages before gaining comfort with the one you’re learning. On each switch, you will restart from zero. It is very easy to get off the path after reading a persuasive article regarding a cool language or a framework. In addition,<a href="https://www.parkersoftware.com/blog/developer-impostor-syndrome-why-you-feel-like-a-fake/#:~:text=In%20fact%2C%20developers%20are%20particularly,against%20the%20skills%20of%20others."> imposter syndrome</a> can discourage you.</p><p>In contrast, the coding bootcamps or 2–4-year colleges provide a predefined schedule, a curriculum and instructors who will teach the students. Thus, you study the material and ask your instructor for guidance as needed. In addition, you have mentors available to give you advice when you need it. In fact, each of these paths have their pros and cons. The advantage of mentors and instructors guiding your learning should not be overlooked; self-taught curriculums require you to find the information and answer your own questions as they arise. It’s already hard enough to become a web developer, but it’s much harder when you don’t have someone giving you assignments and encouraging your progress. The coding bootcamps are challenging because they require a 15 weeks full-time schedule from 9:00 am to 6:00 pm 5 days/week. Additionally, it costs around $13,000 for tuition, and you need about another $10,000 to support yourself while attending the bootcamp. Down the road, you may get tired of studying every day for 8 hours without having an income. Ask yourself these hard questions now before you enroll.</p><p>The last choice is attending a computer science university. However, universities are expensive and require a 4-year commitment to finish. Getting a bachelor’s degree in computer science is awesome, but often comes at a great cost. In addition, you may not be able to finish it in 4 years if you don’t have the budget to pay for 15 credits each semester. None of these paths are easy. But if you decide to take one or mix them based on your budget and time, you will not regret it. Nobody can achieve anything in a field they are not interested in, so it’s important to be as certain as you can be about the path you decide to take. If you only want to do it for the money, you may fail to achieve anything because a job without interest becomes a punishment. Stay consistent and make a decisive decision such that you will become a programmer regardless of the time. It may take from 6 months to 3 years, but if you are passionate about achieving your goal, nothing will stop you.</p><p>To emphasize, if you can’t build a static website or can’t solve basic problems such as using if-else, for-loop and while-loop, then enrolling in a bootcamp may not be right for you yet. Therefore, make sure you can easily manipulate DOM elements in a page using JavaScript. You should feel comfortable with the material in this link (<a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents">Manipulating documents — Learn web development | MDN (mozilla.org)</a>. Some people start their coding career from a coding bootcamp, but they soon realize that their cohorts do much better than them, so they decide to quit. But if you have a strong grasp of the fundamentals, you’ll avoid frustration and imposter syndrome when you begin your bootcamp. This will help you to invest into the bootcamp material rather than googling to learn the coding concept.</p><p>The best advice I can give to anyone considering a bootcamp is to review the following courses first:</p><ul><li><a href="https://eloquentjavascript.net/">Eloquent JavaScript</a></li><li><a href="https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/#basic-javascript">JavaScript Algorithms and Data Structures Certification | freeCodeCamp.org</a></li><li><a href="https://flatironschool.com/free-lessons/intro-javascript/">Intro to JavaScript | Flatiron School</a></li><li><a href="https://algorithm.codingdojo.com/">Your Guide to Learn Programming Algorithms | Coding Dojo</a></li><li><a href="https://www.udacity.com/course/intro-to-javascript--ud803">Intro to Java | JavaScript Programming | Udacity Free Courses</a></li><li><a href="https://flatironschool.com/free-lessons/learn-coding/">Free Intro to Coding | Flatiron School</a></li><li><a href="https://www.devhandbook.com/javascript/dom/dom-manipulation/">How to manipulate the DOM | Dev Handbook</a></li><li><a href="https://www.edx.org/course/introduction-to-computer-science-and-programming-7?index=product&amp;queryID=9e23c4c3663bc451a961b0f3f8a73c8b&amp;position=3">Introduction to Computer Science and Programming Using Python</a><a href="http://www.edx.org/"> edx.org</a></li><li><a href="https://www.freecodecamp.org/learn/back-end-development-and-apis/">Back End Development and APIs Certification | freeCodeCamp.org</a></li><li><a href="https://zellwk.com/blog/crud-express-mongodb/">Building a Simple CRUD app with Node, Express, and MongoDB</a><a href="https://twitter.com/zellwk"> </a><a href="https://medium.com/u/7ec6bd4cf41f">Zell Liew</a></li></ul><p>In conclusion, learn the fundamentals, get comfortable with building a basic CRUD application, know how databases serve the backend servers, and how data travels from a frontend user interface all the way to backend. Once you are comfortable with these concepts, then it may be the right time for you to register at a bootcamp. If you start and stay consistent, you will be a developer one day based on your grit and determination. “Those who never give up, achieve their goals.”</p><p>A special thanks to <a href="https://www.linkedin.com/in/andrewephillips/">@AndrewPhillips</a> who reviewed this article.</p><p><strong>Learning resources:</strong></p><p><a href="http://www.linkedin.com/learning">www.linkedin.com/learning</a></p><p><a href="http://www.edx.org/">www.edx.org</a></p><p><a href="http://www.coursera.com/">www.coursera.com</a></p><p><a href="https://developer.mozilla.org/en-US/">MDN Web Docs (mozilla.org)</a></p><p><a href="http://www.youtube.com/">www.youtube.com</a></p><p><a href="http://www.udacity.com/">www.udacity.com</a></p><p><a href="http://www.udemy.com/">www.udemy.com</a></p><p><a href="https://betterprogramming.pub/11-tricks-to-master-the-art-of-googling-as-a-software-developer-2e00b7568b7d">11 Tricks To Master the Art of Googling as a Software Developer</a></p><p><a href="https://www.linkedin.com/learning/getting-started-as-a-full-stack-web-developer">Getting Started as a Full-Stack Web Developer</a> [LinkedinLearning.com]</p><p><a href="https://www.linkedin.com/learning/programming-foundations-beyond-the-fundamentals">Programming Foundations: Beyond the Fundamentals</a> [LinkedinLearning.com]</p><p><strong>Online browser based IDE to practice:</strong></p><p><a href="https://replit.com/">replit.com</a></p><p>Cited Works</p><p>Erin Doherty, “What is object-oriented programming?” OOP explained in depth” <a href="http://www.educative.io/blog/object-oriented-programming">www.educative.io/blog/object-oriented-programming</a>, 15 April 2020.</p><p>GeeksForGeeks, “Difference Between Class and Object” <a href="http://www.geeksforgeeks.org/difference-between-class-and-object">www.geeksforgeeks.org/difference-between-class-and-object</a>, 24 June 2021.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions/contributors.txt">MDN contributors</a>, “Functions” <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions">developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions</a>, 2 February 2022.</p><p>Codecademy, “Learn JavaScript: Iterators” <a href="https://www.codecademy.com/learn/game-dev-learn-javascript-higher-order-functions-and-iterators/modules/game-dev-learn-javascript-iterators/cheatsheet#:~:text=In%20Javascript%2C%20functions%20can%20be,and%2For%20returns%20a%20function">www.codecademy.com/learn/game-dev-learn-javascript-higher-order-functions-and-iterators/modules/game-dev-learn-javascript-iterators/cheatsheet#:~:text=In%20Javascript%2C%20functions%20can%20be,and%2For%20returns%20a%20function</a>. Accessed on 25 March 2022.</p><p>Codecademy, “What is REST?” <a href="http://www.codecademy.com/article/what-is-rest">www.codecademy.com/article/what-is-rest</a>. Accessed on 25 March 2022.</p><p>Codecademy, “What is CRUD?” <a href="http://www.codecademy.com/article/what-is-crud">www.codecademy.com/article/what-is-crud</a>. Accessed on 25 March 2022.</p><p>Maximilian Schwarzmüller, “Frontend vs Backend” <a href="https://academind.com/tutorials/frontend-vs-backend#:~:text=Frontend%20and%20backend%20communicate%20with,store%20it%20in%20some%20database.">academind.com/tutorials/frontend-vs-backend#:~:text=Frontend%20and%20backend%20communicate%20with,store%20it%20in%20some%20database</a>, 2 July 2020.</p><p>Wikipedia, “Control Flow” <a href="http://en.wikipedia.org/wiki/Control_flow#:~:text=Within%20an%20imperative%20programming%20language,or%20more%20paths%20to%20follow.">en.wikipedia.org/wiki/Control_flow#:~:text=Within%20an%20imperative%20programming%20language,or%20more%20paths%20to%20follow</a>. Accessed on 25 March 2022.</p><p>TechVidvan, “Java Loops — A Complete Guide for Beginners!” <a href="https://techvidvan.com/tutorials/java-loops/#:~:text=In%20Java%2C%20there%20are%20three,generally%20known%20as%20loop%20control">techvidvan.com/tutorials/java-loops/#:~:text=In%20Java%2C%20there%20are%20three,generally%20known%20as%20loop%20control</a>. Accessed on 25 March 2022.</p><p>W3Schools, “Java Data Types” <a href="http://www.w3schools.com/java/java_data_types.asp">www.w3schools.com/java/java_data_types.asp</a>. Accessed on 25 March 2022.</p><p>Oracle, “Primitive Data Types” <a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html</a>. Access on 25 March 2022.</p><p>PARKER SOFTWARE, “Developer impostor syndrome: why you feel like a fake” <a href="https://www.parkersoftware.com/blog/developer-impostor-syndrome-why-you-feel-like-a-fake/#:~:text=In%20fact%2C%20developers%20are%20particularly,against%20the%20skills%20of%20others">www.parkersoftware.com/blog/developer-impostor-syndrome-why-you-feel-like-a-fake/#:~:text=In%20fact%2C%20developers%20are%20particularly,against%20the%20skills%20of%20others</a>. Accessed on 25 March 2022.</p><p><a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents/contributors.txt">MDN contributors</a>, “Manipulating documents” <a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents">developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents</a>. 19 March 2022.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffce70ffd07a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement a Sequential Search Algorithm?]]></title>
            <link>https://menhajharaf.medium.com/how-to-implement-a-sequential-search-algorithm-27d5284237b3?source=rss-693e521cb47b------2</link>
            <guid isPermaLink="false">https://medium.com/p/27d5284237b3</guid>
            <dc:creator><![CDATA[Menhaj Sharaf]]></dc:creator>
            <pubDate>Mon, 19 Jul 2021 03:17:32 GMT</pubDate>
            <atom:updated>2021-07-19T12:52:43.349Z</atom:updated>
            <content:encoded><![CDATA[<p>Searching an element in a list is an essential algorithm and understanding the different types of searching algorithms will help you build a well-designed application which can have good performance. In fact, there are different types of searching algorithms which are developed based on the data-structures (DS) such as Linear and Non-Linear. Linear DS require sequential search because “Data structure where data elements are arranged sequentially or linearly where the elements are attached to its previous and next adjacent in what is called a linear data structure.” (GFG). On the other hand, a non-linear DS require non-sequential algorithms because the list can’t be sequentially searched. A tree is a good example of non-linear DS. In this tutorial, we will implement a sequential search on an unordered list. Even though, sequential search can be used on a sorted list, but it is not efficient. If you do use sequential search on a sorted list, you can stop your search at the number greater than the target value. For example, if there are 10 elements in an array, and you are looking for number 4, if you reach number five without finding 4, then you can exit the loop because 5 is greater than 4 and in a sorted array 4 comes before 5.</p><p>Imagine that there are 100 people in a line. and you are asked to find a person named “John Doe.” Using sequential search, you will start from the first person and keep asking “What is your name?” until you find the person. In the worst-case scenario, you will end up walking to the end of the line without finding the person, or the last person can be the one you are looking for. If the person is standing at the beginning of the line, this is your best-case scenario because it didn’t exhaust you. However, if the person is the 99th or 100th in the line, then you have encountered the worst-case scenario because you exhausted yourself by asking every individual in the line about their identity. Furthermore, in the average-case, the person can be in the middle of the line. This search can as simple as finding one unique element in the array or can get a little complex by having many of identical elements. However, the search process itself is important, but the extra conditions can easily be added to the question the identity of the person that you are looking for. For instance, if you ask the first person “What is your name?” the reply could be “My name is Jon Doe?” now, you can add if-else condition to check for his attributes such as: “What is your ID? Is this person wearing a red shirt?” etc.…</p><p>Now, imagine if the line had a million (n = million) people standing and you are asked to find a unique person. If the person is located at the beginning of the line, not an issue, but we are always concerned with the worst-case scenario, therefore, if the person is located at n-1 (million-1), then it will take much more time to locate the person.</p><p>In the following figure, we want to find the number 6 in an array list. We start at the beginning of the line and loop through the list and keep asking does array of index 0…7 have the element 6? Once found then it returns “true”, otherwise, it returns “false.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9q_Jm5qB8gjVRkrpsyGWJQ.png" /></figure><p>Let’s implement this in JavaScript.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47e8b032ffacbe00360367880718932c/href">https://medium.com/media/47e8b032ffacbe00360367880718932c/href</a></iframe><p>Java implementation</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e3fb32b9f7a825102f1d26f6fddc5b2/href">https://medium.com/media/9e3fb32b9f7a825102f1d26f6fddc5b2/href</a></iframe><p>Tester class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a49bf82d9e55232cac5e49ab57fd6399/href">https://medium.com/media/a49bf82d9e55232cac5e49ab57fd6399/href</a></iframe><ul><li><a href="https://en.wikipedia.org/wiki/Linear_search">Linear search - Wikipedia</a></li><li><a href="https://runestone.academy/runestone/books/published/pythonds/SortSearch/TheSequentialSearch.html">6.3. The Sequential Search - Problem Solving with Algorithms and Data Structures</a></li></ul><p><a href="https://www.geeksforgeeks.org/difference-between-linear-and-non-linear-data-structures/">Difference between Linear and Non-linear Data Structures — GeeksforGeeks</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27d5284237b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement a Generic Queue Data Structure in Java]]></title>
            <link>https://menhajharaf.medium.com/how-to-implement-a-generic-queue-data-structure-in-java-28a853bb1187?source=rss-693e521cb47b------2</link>
            <guid isPermaLink="false">https://medium.com/p/28a853bb1187</guid>
            <dc:creator><![CDATA[Menhaj Sharaf]]></dc:creator>
            <pubDate>Tue, 11 May 2021 16:07:45 GMT</pubDate>
            <atom:updated>2021-05-25T09:45:48.663Z</atom:updated>
            <content:encoded><![CDATA[<p>First of all, let’s review what a generic type is and then review a Queue Data Structure and Algorithm. A generic data type allows programmers to declare a variable without defining or declaring statically the data type. In general, a data type must be declared before instantiating or declaring a variable in Java. However, Java’s generics allow users to create objects without statically declaring the type before the instantiation. One of the basic fundamental of programming is to write a code that you can use it multiple times. Therefore, A generic class type will allow you to use a class and instantiate objects with different data types. For instance, Java’s ArrayList&lt;&gt;, List&lt;&gt; and some other packages/libraries are implemented with generics.</p><p>If you create basic Java class with the main method, you can test the following code. To just review, let’s type the code in either the browser or in the IDE.</p><p><a href="https://www.jdoodle.com/online-java-compiler/">JDoodle - free Online Compiler, Editor for Java, C/C++, etc</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a7ed7b577b07ab5ba69b9b71189e857/href">https://medium.com/media/4a7ed7b577b07ab5ba69b9b71189e857/href</a></iframe><p>//Output<br>// Individual elements in the list: 1 2 3 4 5<br>//The whole list as an array: [1, 2, 3, 4, 5]</p><p>The good thing about the generic is that you can simply instantiate a different object with a different kind of data type.</p><p>// Output<br>// John Wick, Will Smith, Rashid Khan, Jack Jackson, <br>// The list includes: [John Wick, Will Smith, Rashid Khan, Jack Jackson]<br>All we did was to change the object type from Integer to String. Imagine if it wasn’t implemented based on generics. You would have to rewrite a whole class for each data type.</p><p>It is time to review Queue Data Structure before implementing it.</p><p>A queue data structure is implemented on either on an array or on a node. Thus, at its base, it is either an array type or a node type. The algorithm that a user writes defines the queue data structure, therefore, it only allows to remove from the front of the queue and add to the back/tail/rear of the queue. Thus, the algorithm has certain rules to limit interaction with the array or a node-list.</p><p>The way a queue is implemented is that a user can only have access to the front or back of the array or a node. If a user can make changes to the front, middle, at any index location, or at rear, then it will be called a list data structure. In a queue Data Structure, data is added at the rear end of the queue but removed from the front. As a result, it’s called First in First out (FIFO).</p><p>Think of a queue as a tunnel with one way entry and exit. All cars must form a line and enter the tunnel then exit in the same order. Moreover, a queue line to buy a ticket or a line for buying ice-cream where people line up to wait for their turns. Remember, when buyers come to buy ice-cream they form the line, if there is a person already there at the start of the line, then the next individual will go to the rear of the line. Therefore, every individual must stay in the line for their turns. The person who comes first will get his/her ice-cream, then second person and the third person will wait in the queue for his/her turn. Now, there are two situations, first, you can have a fixed size queue. For instance, a small ice-cream shop can only allow 30 people to wait inside the store to get ice-cream. Therefore, the maximum length for people to wait in the line is 30. There is no more space for people to wait. People inside of the store has to wait for their turns to reach the counter in order to get the ice-cream. The second type of the algorithm is to either use a Node based queue or resize the array in order to fit the extra number of people who want to enter the store. This will be an important decision to make because resizing a large array and copying the old data into the new array is an expensive operation. However, there are other types of queue implementations such as circular, resizable and node-based, which will be discussed later.</p><p>Let’s look at the diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lBoh3b7gBbrWtjwBKD8-IA.jpeg" /><figcaption>Queue Data Structure</figcaption></figure><p>The following methods are written in a queue data structure and algorithm: Enqueue(T element) =&gt; Adds element to the tail.<br> Dequeue() =&gt; Removes first/head element.<br> isFull() =&gt; Checks if the queue is full.</p><p>isEmpty() =&gt; Checks if the queue is empty. Returns a Boolean true if the queue is empty.<br> Size() =&gt; Lets the user know about the number of elements inserted in the queue, not the length.<br> On an array-based queue, we declare two pointers such as head and tail to keep tracking of the insertion/enqueue or deletion/dequeue process. There are multiple ways of implementing Queue Data Structure, but the inserting and deleting in a circular way implementation is helpful. Below is the code for Queue implementation. The point to focus is on Enqueue and Dequeue operation, particularly on lines</p><p><strong>tail = (tail+1) % data.length, and, head = (head+1) % data.length</strong>;<br> Let’s assume that we have a queue with the length 10 and decide how to add or delete elements. Remember at the initial instantiation, tail value is the last index which 10–1= 9. Note: we are dividing the integers, so the remainder is either a whole number or a zero, no fractions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtjFSOpjsqiFRZKyYpV36Q.png" /><figcaption>Calculating Index Value</figcaption></figure><p>The modulus % operator calculates the remainder, not the quotient. First tail is holding the value of the last index which is 9, then 1 is added (1+9) which gives 10, so if you divide 10/10 the remainder is 0, but quotient will 1. Therefore, we focus on the remainder. The remainder becomes the new index location for the enqueue operation to take place.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb3c44c4ce5d301e2c783302608bf9ab/href">https://medium.com/media/fb3c44c4ce5d301e2c783302608bf9ab/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b31a4433e991db5b87fc705fbee7524f/href">https://medium.com/media/b31a4433e991db5b87fc705fbee7524f/href</a></iframe><p>A slightly different version:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e67933e61306e14293dc2467ac2936c/href">https://medium.com/media/1e67933e61306e14293dc2467ac2936c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d68b0d0d719d4343a279ac010effb977/href">https://medium.com/media/d68b0d0d719d4343a279ac010effb977/href</a></iframe><p>I will update this article to add circular queue and node list queue…</p><p><a href="https://en.wikipedia.org/wiki/Queue_(abstract_data_type)">https://en.wikipedia.org/wiki/Queue_(abstract_data_type)</a></p><p>Photos: Microsoft Bing CC BY-SA-NC</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28a853bb1187" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Implement A Generic Data Structure In Java]]></title>
            <link>https://medium.com/javarevisited/how-to-implement-a-generic-data-structure-in-java-2523b5c4d3ff?source=rss-693e521cb47b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2523b5c4d3ff</guid>
            <dc:creator><![CDATA[Menhaj Sharaf]]></dc:creator>
            <pubDate>Wed, 21 Apr 2021 04:36:13 GMT</pubDate>
            <atom:updated>2021-07-30T14:22:55.938Z</atom:updated>
            <content:encoded><![CDATA[<h3>How To Implement A Generic Stack Data Structure In Java</h3><p>Java is a statically typed language, it requires the user to define the type of the data before declaring the variable (Oracle). Thus, a programmer who may not know about generics will end up re-writing the same class multiply times to create an object of integer, double and string in order to meet an application’s requirement.</p><p>Therefore, it is important to have a good knowledge of generics in Java. Languages such as <a href="https://medium.com/javarevisited/5-best-javascript-books-for-beginners-and-experienced-web-developers-2c6353d1cc85">JavaScript </a>or <a href="https://medium.com/javarevisited/10-best-python-certification-courses-from-coursera-4576890eb6b3">Python </a>allow users to define the variable without defining the data type.</p><p>As a result, a programmer can use the same class with different data types. However, <a href="https://medium.com/javarevisited/10-best-places-to-learn-java-online-for-free-ce5e713ab5b2">Java </a>is not that flexible, but the need for flexibility in variable declaration and datatypes has led Java developers to create the generic object, which almost behaves similar to non-statically typed languages.</p><p>In this tutorial, we use a generic stack class and data structure to illustrate the benefit of using generics.</p><p>A Generic Class can be written once but used multiple times, which is the principle of <a href="https://medium.com/javarevisited/10-oop-design-principles-you-can-learn-in-2020-f7370cccdd31">Don’t Repeat Yourself</a> (DRY). Let’s review the following generic and non-generic classes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a7ed7b577b07ab5ba69b9b71189e857/href">https://medium.com/media/4a7ed7b577b07ab5ba69b9b71189e857/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15465d4c990d545d9a8f5c80d53d9a1d/href">https://medium.com/media/15465d4c990d545d9a8f5c80d53d9a1d/href</a></iframe><p><a href="https://raw.githubusercontent.com/menhaj007/genericStack/main/Car.java">https://raw.githubusercontent.com/menhaj007/genericStack/main/Car.java</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84529836893ddf613efb84c6dac1d9df/href">https://medium.com/media/84529836893ddf613efb84c6dac1d9df/href</a></iframe><p><a href="https://raw.githubusercontent.com/menhaj007/genericStack/main/Car1.java">https://raw.githubusercontent.com/menhaj007/genericStack/main/Car1.java</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/739f4809d9fa0c6cfd0b765b0f6702c6/href">https://medium.com/media/739f4809d9fa0c6cfd0b765b0f6702c6/href</a></iframe><p><a href="https://raw.githubusercontent.com/menhaj007/genericStack/main/ZipCode.java">https://raw.githubusercontent.com/menhaj007/genericStack/main/ZipCode.java</a></p><p>To instantiate a <a href="https://javarevisited.blogspot.com/2012/08/how-to-write-parametrized-class-method-Generic-example.html#axzz6tWnd7QYO">generic Java class</a>, add &lt;T&gt;or &lt;E&gt; or any other preferred word or letter next to the class name. For example, public class Car&lt;T&gt;, public class Queue&lt;E&gt; or public class Tree&lt;Node&gt;.</p><p>Let’s compare the above two samples /(links) classes:</p><p>There are two key differences in the above examples. The first difference is that a generic class needs to be instantiated with Object Wrappers such as &lt;Integer&gt;, &lt;Double&gt;, &lt;String&gt;. The other difference is that multiple instances of the same class can be created with different data types in the main method.</p><p>On the other hand, in class Car1’s variable type must be defined before creating an instance of it. There will be a need for a new class if the datatype for serialCode and weight needs to be changed. Thus, a generic class can save both time and space when used efficiently.</p><p>Note: A user can define a generic class with multiple key and value pairs such as <a href="https://www.java67.com/2013/02/10-examples-of-hashmap-in-java-programming-tutorial.html">HashMap</a>. For instance, public class Zipcode&lt;code, cityName&gt;.</p><pre>public class ZipCode&lt;code, city&gt; {<br>    code areaCode;<br>    city cityName;<br><br>    public ZipCode(code areaCode, city cityName) {<br>        this.areaCode = areaCode;<br>        this.cityName = cityName;<br>    }<br>    public String toString() {<br>        return &quot;Zip code: &quot; + areaCode + &quot;, City name: &quot; + cityName;<br>    }<br><br>    public static void main(String[] args) {<br>        ZipCode&lt;Integer, String&gt; alexandria = new ZipCode&lt;&gt;(22304, &quot;Alexandria&quot;);<br>        ZipCode&lt;Integer, String&gt; fairfax = new ZipCode&lt;&gt;(22030, &quot;Fairfax&quot;);<br>        System.out.println(alexandria);<br>        System.out.println(fairfax);<br>        ZipCode&lt;Long, String&gt; Himalaya = new ZipCode&lt;&gt;(33939932223L, &quot;Himalaya&quot;);<br>        System.out.println(Himalaya);<br><br>    }<br>}</pre><p><a href="https://raw.githubusercontent.com/menhaj007/genericStack/main/ZipCode.java">https://raw.githubusercontent.com/menhaj007/genericStack/main/ZipCode.java</a></p><p>In order to allow a number longer than the integer’s capacity, all it needed was to replace &lt;Integer, String&gt; with &lt;Long, String&gt;.</p><p>Let’s review the <a href="https://www.java67.com/2013/08/ata-structures-in-java-programming-array-linked-list-map-set-stack-queue.html">Stack Data Structure</a> before implementation. A stack is a Last In First Out (LIFO) data structure (Wikipedia). This means when a programmer decides to design a stack data structure, he/she implements at least the following methods or algorithms:</p><p>pop(), push(), top(), isFull(), isEmpty() and size(). One of the commonly used data structures in a stack is an <a href="https://medium.com/javarevisited/20-array-coding-problems-and-questions-from-programming-interviews-869b475b9121?source=---------33------------------">array object</a>. In Java, the size and data type of an array must be defined at the time of instantiation. Otherwise, it will throw error. Let’s compare JavaScript’s array and Java’s Array.</p><p>JavaScript: let myArray = []</p><p>Java: int[] myArray = new int[10], <br>or <br>data-type[] variable = new data-type[size]</p><p>By looking at Java’s array implementation, it is clear that if a programmer needs to create an <a href="https://javarevisited.blogspot.com/2013/11/java-array-101-for-programmers-and.html">array of strings</a>, then he/she must redo the whole work, unless a generic object is used. In general, datatypes must be statically typed before declaring the variables.</p><p>If a programmer doesn’t use a generic datatype for <a href="https://javarevisited.blogspot.com/2017/03/how-to-implement-stack-in-java-using-array-example.html#axzz6eho0TYnf">implementing a stack data structure</a>, and if the need for having multiple types of the stack or other classes rise, then the programmer has to create multiples of similar stacks or classes.</p><p>The followings are sample implementations of integer stack, string stack, and generic stacks:</p><figure><a href="https://javarevisited.blogspot.com/2017/03/difference-between-stack-and-queue-data-structure-in-java.html#axzz5dxZIUUxy"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_5XK_PYacZbOAGDO8l3ULA.jpeg" /></a><figcaption>Stack Data Structure</figcaption></figure><p><a href="https://raw.githubusercontent.com/menhaj007/genericStack/main/IntStack.java">https://raw.githubusercontent.com/menhaj007/genericStack/main/IntStack.java</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70ce0b864b8ece8f24ad5f547ab40397/href">https://medium.com/media/70ce0b864b8ece8f24ad5f547ab40397/href</a></iframe><p><a href="https://raw.githubusercontent.com/menhaj007/genericStack/main/StringStack.java">https://raw.githubusercontent.com/menhaj007/genericStack/main/StringStack.java</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/418085894711b3e822373474d18eebe4/href">https://medium.com/media/418085894711b3e822373474d18eebe4/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9257e27ee55adb9fbe997e225780a15/href">https://medium.com/media/d9257e27ee55adb9fbe997e225780a15/href</a></iframe><p><a href="https://raw.githubusercontent.com/menhaj007/genericStack/main/Stack.java">https://raw.githubusercontent.com/menhaj007/genericStack/main/Stack.java</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5c287516bee19595fdb030f9789ed45/href">https://medium.com/media/c5c287516bee19595fdb030f9789ed45/href</a></iframe><p><a href="https://raw.githubusercontent.com/menhaj007/genericStack/main/Main.java">https://raw.githubusercontent.com/menhaj007/genericStack/main/Main.java</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGgeDnjgdEk8%3Fstart%3D1456%26feature%3Doembed%26start%3D1456&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGgeDnjgdEk8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGgeDnjgdEk8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0d5ef974ebdca5b23650c13c40c470c/href">https://medium.com/media/f0d5ef974ebdca5b23650c13c40c470c/href</a></iframe><ul><li><a href="https://en.wikipedia.org/wiki/Stack_(abstract_data_type)">Stack (abstract data type) - Wikipedia</a></li><li><a href="https://opendatastructures.org/">Open Data Structures</a></li><li><a href="https://docs.oracle.com/cd/E57471_01/bigData.100/extensions_bdd/src/cext_transform_typing.html">Dynamic typing vs. static typing</a></li><li><a href="https://www.geeksforgeeks.org/stack-data-structure-introduction-program/">Stack Data Structure (Introduction and Program) - GeeksforGeeks</a></li><li><a href="https://algs4.cs.princeton.edu/13stacks/">Bags, Queues, and Stacks. Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.</a></li><li><a href="https://medium.com/javarevisited/7-best-courses-to-learn-data-structure-and-algorithms-d5379ae2588">7 Best Courses to learn Data Structure and Algorithms</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2523b5c4d3ff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javarevisited/how-to-implement-a-generic-data-structure-in-java-2523b5c4d3ff">How To Implement A Generic Data Structure In Java</a> was originally published in <a href="https://medium.com/javarevisited">Javarevisited</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>