{"id":27010516,"url":"https://github.com/burakboduroglu/data_structures_and_algorithms","last_synced_at":"2025-04-04T11:05:25.902Z","repository":{"id":165170700,"uuid":"580140913","full_name":"burakboduroglu/data_structures_and_algorithms","owner":"burakboduroglu","description":"This repo contains my sata structures and algorithms codes.","archived":false,"fork":false,"pushed_at":"2024-07-24T13:44:14.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-24T15:51:42.715Z","etag":null,"topics":["alghorithm","data","data-structures","dynamic-programming","graph","hash","interview","interview-questions","linked-list","structures","tree-structure"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/burakboduroglu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-19T20:26:09.000Z","updated_at":"2024-07-24T13:44:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"b002be60-b0f1-427e-81ff-f93aada76683","html_url":"https://github.com/burakboduroglu/data_structures_and_algorithms","commit_stats":null,"previous_names":["burakboduroglu/data_structures_and_algorithms"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burakboduroglu%2Fdata_structures_and_algorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burakboduroglu%2Fdata_structures_and_algorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burakboduroglu%2Fdata_structures_and_algorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burakboduroglu%2Fdata_structures_and_algorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/burakboduroglu","download_url":"https://codeload.github.com/burakboduroglu/data_structures_and_algorithms/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166173,"owners_count":20894654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alghorithm","data","data-structures","dynamic-programming","graph","hash","interview","interview-questions","linked-list","structures","tree-structure"],"created_at":"2025-04-04T11:05:25.291Z","updated_at":"2025-04-04T11:05:25.891Z","avatar_url":"https://github.com/burakboduroglu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Welcome to Data Structures and Algorithms Repository 👋\n\nThis repository contains the implementation of various data structures and algorithms in JavaScript. However, you can implement them in any programming language of your choice. If you find any issues or have any suggestions, feel free to open an issue or create a pull request.\n\n## What is Data Structures and Algorithms?\n\n- `Data Structures` are the way we store, organize, and manage data.\n- `Algorithms` are a set of steps to solve a particular problem.\n\n## Why should we use Data Structures and Algorithms?\n\nThey are essential tools for solving complex problems in computer science. They help us to write efficient code and improve the performance of our applications.\n\n## What is Big O Notation?\n\nBig O Notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. It is used to analyze the performance of an algorithm.\nFor instance - O(1), O(n), O(log n), O(n^2), etc.\n\n- O(1) - Constant Time\n- O(n) - Linear Time\n- O(log n) - Logarithmic Time\n- O(n^2) - Quadratic Time\n- O(2^n) - Exponential Time\n\nBest Case - The minimum time taken by an algorithm to solve a problem. (e.g., O(1))\n\nWorst Case - The maximum time taken by an algorithm to solve a problem. (e.g., O(n^2))\n\n`Example 1`\nHere is an O(1) example:\n\n```javascript\nfunction add(a, b) {\n  return a + b;\n}\n```\n\n`Example 2`\nHere is an O(n) example:\n\n```javascript\nfunction sum(arr) {\n  let total = 0;\n  for (let i = 0; i \u003c arr.length; i++) {\n    total += arr[i];\n  }\n  return total;\n}\n```\n\nEach loop iteration increases the total time complexity by 1. Hence, the time complexity of the above function is O(n). If nested loops are used, the time complexity will be O(n^2).\n\n`Example 3`\nO(log n) example is binary search. We will cover this in the algorithms section.\n\n## Arrays\n\nArrays are a collection of elements stored in contiguous memory locations. They are used to store multiple values in a single variable. The elements in an array can be accessed using an index.\n\nWe are covering the following array challenges:\n\n- Reverse String\n- Palindromes\n- Integer Reversal\n- Sentence Capitalization\n- FizzBuzz\n- Max Profit\n- Array Chunk\n- Two Sum\n\n### Creating custom array:\n\n1. Create an array class.\n2. Implement the following methods:\n   - constructor\n   - push\n   - pop\n   - get\n   - shift\n   - deleteByIndex\n3. Test the methods.\n\nYou can find the implementation of the above challenges in the [Arrays](Arrays/index.js) folder.\nIn this folder, you will learn how to create custom arrays and implement the above challenges.\n\n### Reverse String:\n\nTask reverse a given array and convert it to a string.\n\n```javascript\nconst myArray = [\"B\", \"U\", \"R\", \"A\", \"K\"];\n\nconst reverse = (arr) =\u003e {\n  let reversed = [];\n  for (let i = arr.length - 1; i \u003e= 0; i--) {\n    reversed.push(arr[i]);\n  }\n  return reversed;\n};\n\nconsole.log(reverse(myArray)); // [ 'K', 'A', 'R', 'U', 'B' ]\n\nconst reversedNameString = reverse(myArray).join(\"\");\nconsole.log(reversedNameString); // KARUB\n```\n\n### Palindromes:\n\nTask check if a given string is a palindrome. Palindrome is a word, phrase, or sequence that reads the same backward as forward.\n\n```javascript\nconst isPalindrome = (word) =\u003e {\n  const reversedWord = word.split(\"\").reverse().join(\"\");\n  if (word === reversedWord) {\n    return true;\n  }\n  return false;\n};\n\nconsole.log(isPalindrome(\"racecar\")); // true\nconsole.log(isPalindrome(\"hello\")); // false\n```\n\n### Reverse Integer:\n\nTask reverse a given integer.\n\n```javascript\n// Solution 1\nconst reverseInteger1 = (num) =\u003e {\n  return (reversed = num.toString().split(\"\").reverse().join(\"\"));\n};\n\nconsole.log(reverseInteger1(123)); // \"321\"\n\n// Solution 2\nconst reverseInteger2 = (num) =\u003e {\n  let reversed = 0;\n  while (num \u003e 0) {\n    reversed = reversed * 10 + (num % 10);\n    num = Math.floor(num / 10);\n  }\n  return reversed;\n};\n\nconsole.log(reverseInteger2(123)); // 321\n```\n\n### Sentence Capitalization:\n\nTask capitalize the first letter of each word in a sentence.\n\n```javascript\nconst capitalize = (str) =\u003e {\n  arr = str.split(\"\");\n  arr.map((char, index) =\u003e {\n    if (index === 0) {\n      arr[index] = char.toUpperCase();\n    } else if (arr[index - 1] === \" \") {\n      arr[index] = char.toUpperCase();\n    }\n  });\n\n  return arr.join(\"\");\n};\n\nconsole.log(capitalize(\"hello\")); // \"Hello\"\nconsole.log(capitalize(\"hello world\")); // \"Hello World\"\n```\n\n### FizzBuzz:\n\nTask print numbers from 1 to n. If the number is divisible by 3, print \"Fizz\". If the number is divisible by 5, print \"Buzz\". If the number is divisible by both 3 and 5, print \"FizzBuzz\".\n\n```javascript\nfunction fizzBuzz(num){\n   if(num % 3 === 0) return \"Fizz\";\n   else if(num % 5 === 0) return \"Buzz\";\n   else if(num % 3 === 0 \u0026\u0026 num % 5 === 0) return \"FizzBuzz\";\n   else return \"Not a FizzBuzz\";\n}\n\nconsole.log(fizzBuzz(3)); // Fizz\nconsole.log(fizzBuzz(5)); // Buzz\nconsole.log(fizzBuzz(15)); // FizzBuzz\nconsole.log(fizzBuzz(7)); // Not a FizzBuzz\n```\n\n### Max Profit:\n\nFind the maximum profit that can be made by buying and selling a stock on a given day.\n\n```javascript\nfunction maxProfit(arr){\n    let minPrice = findMinNumber(arr)\n    let maxProfit = 0;\n\n    for(let i=0; i\u003carr.length; i++){\n        if(arr[i] \u003e minPrice){\n            maxProfit = Math.max(maxProfit, arr[i] - minPrice);\n        } else {\n            minPrice = arr[i];\n        }\n    }\n    return maxProfit;\n}\n\nfunction findMinNumber(arr){\n    let min = arr[0];\n    for(let i=0; i\u003carr.length; i++){\n        if(arr[i] \u003c min){\n            min = arr[i];\n        }\n    }\n    return min;\n}\n\nconst prices = [7,1,5,3,6,4];\nconsole.log(maxProfit(prices)); // 6\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburakboduroglu%2Fdata_structures_and_algorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fburakboduroglu%2Fdata_structures_and_algorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburakboduroglu%2Fdata_structures_and_algorithms/lists"}