{"id":24438710,"url":"https://github.com/anower77/data-structures-algorithm-dsa-","last_synced_at":"2025-03-14T00:13:13.730Z","repository":{"id":188705569,"uuid":"679230782","full_name":"Anower77/Data-Structures-Algorithm-DSA-","owner":"Anower77","description":"Data structures are formats for organizing and storing data, like arrays, linked lists, trees, and graphs. Algorithms are systematic instructions for performing tasks, such as sorting and searching. These structures and algorithms are integral to computing, enhancing data manipulation.","archived":false,"fork":false,"pushed_at":"2023-08-16T13:13:50.000Z","size":610,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T19:17:31.814Z","etag":null,"topics":["algorithms-and-data-structures","analysis","binary-search","bubble-sort","charcounter","dsa","dsa-algorithm","linear-programming","linearsearch","logarithm"],"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/Anower77.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}},"created_at":"2023-08-16T11:36:14.000Z","updated_at":"2023-08-16T13:03:59.000Z","dependencies_parsed_at":"2023-08-16T15:54:14.288Z","dependency_job_id":null,"html_url":"https://github.com/Anower77/Data-Structures-Algorithm-DSA-","commit_stats":null,"previous_names":["anower77/data-structures-algorithm-dsa-"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anower77%2FData-Structures-Algorithm-DSA-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anower77%2FData-Structures-Algorithm-DSA-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anower77%2FData-Structures-Algorithm-DSA-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anower77%2FData-Structures-Algorithm-DSA-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Anower77","download_url":"https://codeload.github.com/Anower77/Data-Structures-Algorithm-DSA-/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243500798,"owners_count":20300774,"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":["algorithms-and-data-structures","analysis","binary-search","bubble-sort","charcounter","dsa","dsa-algorithm","linear-programming","linearsearch","logarithm"],"created_at":"2025-01-20T19:17:33.911Z","updated_at":"2025-03-14T00:13:13.704Z","avatar_url":"https://github.com/Anower77.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## \u003cb\u003eMinimum \u0026 Maximum (DSA)\u003c/b\u003e\n\n\n```javascript\nfunction min5Log(n){\n    for(let i = 0; i \u003c= Math.min(5, n); i++){\n        console.log(i)\n    }\n}\n// min5Log(90000000000000)\n\n// maximum\nfunction max5Log(n){\n    for(let i = 0; i \u003c= Math.max(10, n); i++){\n        console.log(i)\n    }\n}\n\nmax5Log(-1)\n\n```\n## Visualization (min\u0026max)\n\u003cimg src=\"visualization/min\u0026max.png\" height=auto width=auto/\u003e\n\n\n[Visualize code](https://pythontutor.com/render.html#code=function%20min5Log%28n%29%7B%0A%20%20%20%20for%28let%20i%20%3D%200%3B%20i%20%3C%3D%20Math.min%285,%20n%29%3B%20i%2B%2B%29%7B%0A%20%20%20%20%20%20%20%20console.log%28i%29%0A%20%20%20%20%7D%0A%7D%0A//%20min5Log%2890000000000000%29%0A%0A//%20maximum%0Afunction%20max5Log%28n%29%7B%0A%20%20%20%20for%28let%20i%20%3D%200%3B%20i%20%3C%3D%20Math.max%2810,%20n%29%3B%20i%2B%2B%29%7B%0A%20%20%20%20%20%20%20%20console.log%28i%29%0A%20%20%20%20%7D%0A%7D%0A%0Amax5Log%28-1%29\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n\n\n\n## \u003cb\u003eSum Of Array (DSA)\u003c/b\u003e\n\n\n```javascript\n// space complexity o(1), o(n)\n\nfunction sumOfArray(arr){\n    total = 0\n    for(let i = 0; i \u003c arr.length; i++){\n        total = arr[i]\n    }\n    return total\n}\n\n// console.log(sumOfArray([25, 25, 50]))\n\n\n\n// another example\nfunction sumOfArray(arr){\n    newArr = []\n    for(let i = 0; i \u003c arr.length; i++){\n        newArr.push(arr[i] *2)\n    }\n    return newArr\n}\n\nconsole.log(sumOfArray([25, 25, 50]))\n\n```\n## Visualization (sumOfArray)\n\u003cimg src=\"visualization/sumOfArray.png\" height=auto width=auto/\u003e\n\n\n[Visualize code -(sumOfArray)](https://pythontutor.com/render.html#code=//%20space%20complexity%20o%281%29,%20o%28n%29%0A%0Afunction%20sumOfArray%28arr%29%7B%0A%20%20%20%20total%20%3D%200%0A%20%20%20%20for%28let%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%2B%2B%29%7B%0A%20%20%20%20%20%20%20%20total%20%3D%20arr%5Bi%5D%0A%20%20%20%20%7D%0A%20%20%20%20return%20total%0A%7D%0A%0A//%20console.log%28sumOfArray%28%5B25,%2025,%2050%5D%29%29%0A%0A%0A%0A//%20another%20example%0Afunction%20sumOfArray%28arr%29%7B%0A%20%20%20%20newArr%20%3D%20%5B%5D%0A%20%20%20%20for%28let%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%2B%2B%29%7B%0A%20%20%20%20%20%20%20%20newArr.push%28arr%5Bi%5D%20*2%29%0A%20%20%20%20%7D%0A%20%20%20%20return%20newArr%0A%7D%0A%0Aconsole.log%28sumOfArray%28%5B25,%2025,%2050%5D%29%29\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n\n\n\n\n## \u003cb\u003echaracter Count (DSA)\u003c/b\u003e\n\n\n```javascript\nfunction charCount(str){\n    let charList = {}\n\n    for (let i = 0; i \u003c str.length; i++){\n       let char = str[i].toLowerCase()\n\n       if(charList[char] \u003e 0){\n        charList[char]++\n       }else{\n        charList[char] = 1\n       }\n    }\n    return charList\n}\nconsole.table(charCount(\"Anower hossain\"))\n```\n\n## Visualization (charCount)\n\u003cimg src=\"visualization/charCount.png\" height=auto width=auto/\u003e\n\n[Visualize code -(charCount)](https://pythontutor.com/render.html#code=function%20charCount%28str%29%7B%0A%20%20%20%20let%20charList%20%3D%20%7B%7D%0A%0A%20%20%20%20for%20%28let%20i%20%3D%200%3B%20i%20%3C%20str.length%3B%20i%2B%2B%29%7B%0A%20%20%20%20%20%20%20let%20char%20%3D%20str%5Bi%5D.toLowerCase%28%29%0A%0A%20%20%20%20%20%20%20if%28charList%5Bchar%5D%20%3E%200%29%7B%0A%20%20%20%20%20%20%20%20charList%5Bchar%5D%2B%2B%0A%20%20%20%20%20%20%20%7Delse%7B%0A%20%20%20%20%20%20%20%20charList%5Bchar%5D%20%3D%201%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20charList%0A%7D%0Aconsole.table%28charCount%28%22Anower%20hossain%22%29%29\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n\n\n\n\n\n\n\n\n## \u003cb\u003eBinary Search (DSA)\u003c/b\u003e\n\n\n```javascript\nfunction binarySearch(arr, value){\n    let start = 0\n    let end = arr.length -1\n\n\n    while(start \u003c= end){\n        let middle = Math.round((start + end) / 2) // use floor \n\n        if(arr[middle] === value) return middle\n\n        if(value \u003e arr[middle]){\n            start = middle + 1\n        }else if(value \u003c arr[middle]){\n            end = middle -1\n        }\n\n\n    }\n    return -1\n}\nconsole.log(binarySearch([2,3,4,7,34,66], 7))\n\n```\n\n## Visualization (binarySearch)\n\u003cimg src=\"visualization/binarySearch.png\" height=auto width=auto/\u003e\n\n[Visualize code -(binarySearch)](https://pythontutor.com/render.html#code=function%20binarySearch%28arr,%20value%29%7B%0A%20%20%20%20let%20start%20%3D%200%0A%20%20%20%20let%20end%20%3D%20arr.length%20-1%0A%0A%0A%20%20%20%20while%28start%20%3C%3D%20end%29%7B%0A%20%20%20%20%20%20%20%20let%20middle%20%3D%20Math.round%28%28start%20%2B%20end%29%20/%202%29%20//%20use%20floor%20%0A%0A%20%20%20%20%20%20%20%20if%28arr%5Bmiddle%5D%20%3D%3D%3D%20value%29%20return%20middle%0A%0A%20%20%20%20%20%20%20%20if%28value%20%3E%20arr%5Bmiddle%5D%29%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20start%20%3D%20middle%20%2B%201%0A%20%20%20%20%20%20%20%20%7Delse%20if%28value%20%3C%20arr%5Bmiddle%5D%29%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20end%20%3D%20middle%20-1%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%20%20%20%20%7D%0A%20%20%20%20return%20-1%0A%7D%0Aconsole.log%28binarySearch%28%5B2,3,4,7,34,66%5D,%207%29%29\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n\n\n\n\n\n## \u003cb\u003e Recursion (DSA)\u003c/b\u003e\n\n\n```javascript\n\nfunction countDown(n){\n    // normal method\n    // for(let i = n; i \u003e 0; i--){\n    //     console.log(i)\n    // }\n    // Recursin methods\n    console.log(n)\n    n-- \n    if(n \u003e 0) {\n        countDown(n)\n    }\n}\n// countDown(10)\n\n\n//Another example\nfunction sumOfNumber(n){\n    let sum = 0\n    for(let i = n; i \u003e= 0; i--){\n        sum += i\n    }\n    return sum\n}\n\n// console.log(sumOfNumber(10))\n\n//Recursion \nfunction sumOfNumberRe(n){\n    if(n \u003c 0)return 0\n    \n\n    return n + sumOfNumberRe(n - 1)\n}\n\nconsole.log(sumOfNumberRe(10))\n\n/*\nOperation\n============\n10 + 9\n19 + 8\n27 + 7\n34 + 6\n40 + 5\n45 + 4\n49 + 3\n52 + 2\n54 + 1\n55 + 0\n\nfinel result = 55\n*/\n\n```\n\n## Visualization (recursion)\n\u003cimg src=\"visualization/recursion.png\" height=auto width=auto/\u003e\n\n[Visualize code -(recursion)](https://pythontutor.com/render.html#code=function%20countDown%28n%29%7B%0A%20%20%20%20//%20normal%20method%0A%20%20%20%20//%20for%28let%20i%20%3D%20n%3B%20i%20%3E%200%3B%20i--%29%7B%0A%20%20%20%20//%20%20%20%20%20console.log%28i%29%0A%20%20%20%20//%20%7D%0A%20%20%20%20//%20Recursin%20methods%0A%20%20%20%20console.log%28n%29%0A%20%20%20%20n--%20%0A%20%20%20%20if%28n%20%3E%200%29%20%7B%0A%20%20%20%20%20%20%20%20countDown%28n%29%0A%20%20%20%20%7D%0A%7D%0A//%20countDown%2810%29%0A%0A%0A//Another%20example%0Afunction%20sumOfNumber%28n%29%7B%0A%20%20%20%20let%20sum%20%3D%200%0A%20%20%20%20for%28let%20i%20%3D%20n%3B%20i%20%3E%3D%200%3B%20i--%29%7B%0A%20%20%20%20%20%20%20%20sum%20%2B%3D%20i%0A%20%20%20%20%7D%0A%20%20%20%20return%20sum%0A%7D%0A%0A//%20console.log%28sumOfNumber%2810%29%29%0A%0A//Recursion%20%0Afunction%20sumOfNumberRe%28n%29%7B%0A%20%20%20%20if%28n%20%3C%200%29return%200%0A%20%20%20%20%0A%0A%20%20%20%20return%20n%20%2B%20sumOfNumberRe%28n%20-%201%29%0A%7D%0A%0Aconsole.log%28sumOfNumberRe%2810%29%29%0A%0A/*%0AOperation%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A10%20%2B%209%0A19%20%2B%208%0A27%20%2B%207%0A34%20%2B%206%0A40%20%2B%205%0A45%20%2B%204%0A49%20%2B%203%0A52%20%2B%202%0A54%20%2B%201%0A55%20%2B%200%0A%0Afinel%20result%20%3D%2055%0A*/\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n\n\n\n\n\n\n## \u003cb\u003e Proble Solving(DSA)\u003c/b\u003e\n\n\n```javascript\nlet temperature = [-2, 4, 45, \"error\", -6, -8, 43]\n\nfunction getHigherAndLower(arr){\n    // make a higher variable\n    let higher = arr[0]\n    \n    // make a lower variable\n    let lower = arr[0]\n\n    // iterate the whole Array\n    for(let i = 0; i \u003c arr.length; i++){\n    \n    // let's check is there has any error\n    if(typeof arr[i] !== \"number\") continue \n    console.log(typeof arr[i])\n\n\n    // if higher variable has smaller number than our current number than value will be our current element\n    if(higher \u003c arr[i]){\n        higher = arr[i]\n    }\n    \n    // if lower variable has bigger number than our current number than value will be our current element\n    if(lower \u003e arr[i]){\n        lower = arr[i]\n    }\n}\n    \n    \n    // return our higher variable and lower variable\n    return higher - lower\n\n}\n\n// getHigherAndLower([3, 5, -9])\n// getHigherAndLower(temperature)\n\n\nconsole.log(getHigherAndLower(temperature))\n\n```\n\n## Visualization (problesolving)\n\u003cimg src=\"visualization/problesolving.png\" height=auto width=auto/\u003e\n\n[Visualize code -(problesolving)](https://pythontutor.com/render.html#code=let%20temperature%20%3D%20%5B-2,%204,%2045,%20%22error%22,%20-6,%20-8,%2043%5D%0A%0Afunction%20getHigherAndLower%28arr%29%7B%0A%20%20%20%20//%20make%20a%20higher%20variable%0A%20%20%20%20let%20higher%20%3D%20arr%5B0%5D%0A%20%20%20%20%0A%20%20%20%20//%20make%20a%20lower%20variable%0A%20%20%20%20let%20lower%20%3D%20arr%5B0%5D%0A%0A%20%20%20%20//%20iterate%20the%20whole%20Array%0A%20%20%20%20for%28let%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%2B%2B%29%7B%0A%20%20%20%20%0A%20%20%20%20//%20let's%20check%20is%20there%20has%20any%20error%0A%20%20%20%20if%28typeof%20arr%5Bi%5D%20!%3D%3D%20%22number%22%29%20continue%20%0A%20%20%20%20console.log%28typeof%20arr%5Bi%5D%29%0A%0A%0A%20%20%20%20//%20if%20higher%20variable%20has%20smaller%20number%20than%20our%20current%20number%20than%20value%20will%20be%20our%20current%20element%0A%20%20%20%20if%28higher%20%3C%20arr%5Bi%5D%29%7B%0A%20%20%20%20%20%20%20%20higher%20%3D%20arr%5Bi%5D%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20//%20if%20lower%20variable%20has%20bigger%20number%20than%20our%20current%20number%20than%20value%20will%20be%20our%20current%20element%0A%20%20%20%20if%28lower%20%3E%20arr%5Bi%5D%29%7B%0A%20%20%20%20%20%20%20%20lower%20%3D%20arr%5Bi%5D%0A%20%20%20%20%7D%0A%7D%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20//%20return%20our%20higher%20variable%20and%20lower%20variable%0A%20%20%20%20return%20higher%20-%20lower%0A%0A%7D%0A%0A//%20getHigherAndLower%28%5B3,%205,%20-9%5D%29%0A//%20getHigherAndLower%28temperature%29%0A%0A%0Aconsole.log%28getHigherAndLower%28temperature%29%29\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n\n\n\n\n\n\n\n\n## \u003cb\u003eAnalyze BigO (DSA)\u003c/b\u003e\n\n\n```javascript\nfunction uniqueName(arr){\n\n    let uniqueName = []\n    for(let i = 0; i \u003c arr.length; i++){\n        let ele = arr[i]\n        if(!uniqueName.includes(ele)){\n            uniqueName.push(ele)\n        }\n    }\n    return uniqueName\n}\n\n\nlet nameArray = ['anower', 'shanto', 'rohan', 'rohan']\nconsole.log(uniqueName(nameArray)) \n\n```\n\n## Visualization (analyzeBigO)\n\u003cimg src=\"visualization/analyzeBigO.png\" height=auto width=auto/\u003e\n\n[Visualize code -(analyzeBigO)](https://pythontutor.com/render.html#code=function%20uniqueName%28arr%29%7B%0A%0A%20%20%20%20let%20uniqueName%20%3D%20%5B%5D%0A%20%20%20%20for%28let%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%2B%2B%29%7B%0A%20%20%20%20%20%20%20%20let%20ele%20%3D%20arr%5Bi%5D%0A%20%20%20%20%20%20%20%20if%28!uniqueName.includes%28ele%29%29%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20uniqueName.push%28ele%29%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20uniqueName%0A%7D%0A%0A%0Alet%20nameArray%20%3D%20%5B'anower',%20'shanto',%20'rohan',%20'rohan'%5D%0Aconsole.log%28uniqueName%28nameArray%29%29\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n\n## \u003cb\u003e Bubble Sort(DSA)\u003c/b\u003e\n\n\n```javascript\n// bubble Sort implementation\n\nfunction bubbleSort(arr){\n    let isSwap\n    for(let i = 0; i \u003c arr.length; i++){\n        isSwap = false\n        for(let j = 0; j \u003c arr.length -i -1; j++){\n        console.log(\"Swap = \", arr, arr[j], arr[j+1])\n        if(arr[j] \u003e arr[j+1]){\n            let temp = arr[j]\n            arr[j] = arr[j+1]\n            arr[j+1] = temp\n            isSwap = true\n           }\n        }\n        if(!isSwap) break\n    }\n    return arr\n}\n\nconsole.log(bubbleSort([2, 53, 23, 1, -3]))\n\n```\n\n## Visualization (bubbleSort)\n\u003cimg src=\"visualization/bubbleSort.png\" height=auto width=auto/\u003e\n\n[Visualize code -(bubbleSort)](https://pythontutor.com/render.html#code=//%20bubble%20Sort%20implementation%0A%0Afunction%20bubbleSort%28arr%29%7B%0A%20%20%20%20let%20isSwap%0A%20%20%20%20for%28let%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%2B%2B%29%7B%0A%20%20%20%20%20%20%20%20isSwap%20%3D%20false%0A%20%20%20%20%20%20%20%20for%28let%20j%20%3D%200%3B%20j%20%3C%20arr.length%20-i%20-1%3B%20j%2B%2B%29%7B%0A%20%20%20%20%20%20%20%20console.log%28%22Swap%20%3D%20%22,%20arr,%20arr%5Bj%5D,%20arr%5Bj%2B1%5D%29%0A%20%20%20%20%20%20%20%20if%28arr%5Bj%5D%20%3E%20arr%5Bj%2B1%5D%29%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20let%20temp%20%3D%20arr%5Bj%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20arr%5Bj%5D%20%3D%20arr%5Bj%2B1%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20arr%5Bj%2B1%5D%20%3D%20temp%0A%20%20%20%20%20%20%20%20%20%20%20%20isSwap%20%3D%20true%0A%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if%28!isSwap%29%20break%0A%20%20%20%20%7D%0A%20%20%20%20return%20arr%0A%7D%0A%0Aconsole.log%28bubbleSort%28%5B2,%2053,%2023,%201,%20-3%5D%29%29\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n## \u003cb\u003e Linear Search (DSA)\u003c/b\u003e\n\n\n```javascript\n\n\n```\n\n## Visualization (linearSearch)\n\u003cimg src=\"visualization/linearSearch.png\" height=auto width=auto/\u003e\n\n[Visualize code -(linearSearch)](https://pythontutor.com/render.html#code=function%20linearSearch%28arr,%20value%29%7B%0A%20%20%20%20for%28let%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%2B%2B%29%7B%0A%20%20%20%20%20%20%20%20if%28arr%5Bi%5D%20%3D%3D%20value%29%20return%20i%0A%20%20%20%20%7D%0A%20%20%20%20return%20-1%0A%7D%0A%0Aconsole.log%28linearSearch%28%5B2,3,4,5,6%5D,%205%29%29%0A//%20console.log%28linearSearch%28%5B%22anower%22,%20%22shanto%22,%20%22sajib%22,%20%22rohan%22%5D,%22anower%22%29%29\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n\n\n## \u003cb\u003e Helper Function(DSA)\u003c/b\u003e\n\n\n```javascript\n// statement \n// find the odd number and push empty array\n\nfunction findOddNumber(arr){\n\n    let result = []\n    function helper(input){\n        if(input.length === 0) return\n\n        if(input[0] % 2 !== 0){\n            result.push(input[0])\n        }\n\n        helper(input.slice(1))\n    }\n\n    helper(arr)\n\n    return result //if someone say find length just add (result.length)\n}\n\nconsole.log(findOddNumber([2,3,56,8, 3, 6, 8, 5]))\n\n```\n\n## Visualization (helperFunction)\n\u003cimg src=\"visualization/helperFunction.png\" height=auto width=auto/\u003e\n\n[Visualize code -(helperFunction)](https://pythontutor.com/render.html#code=//%20statement%20%0A//%20find%20the%20odd%20number%20and%20push%20empty%20array%0A%0Afunction%20findOddNumber%28arr%29%7B%0A%0A%20%20%20%20let%20result%20%3D%20%5B%5D%0A%20%20%20%20function%20helper%28input%29%7B%0A%20%20%20%20%20%20%20%20if%28input.length%20%3D%3D%3D%200%29%20return%0A%0A%20%20%20%20%20%20%20%20if%28input%5B0%5D%20%25%202%20!%3D%3D%200%29%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20result.push%28input%5B0%5D%29%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20helper%28input.slice%281%29%29%0A%20%20%20%20%7D%0A%0A%20%20%20%20helper%28arr%29%0A%0A%20%20%20%20return%20result%20//if%20someone%20say%20find%20length%20just%20add%20%28result.length%29%0A%7D%0A%0Aconsole.log%28findOddNumber%28%5B2,3,56,8,%203,%206,%208,%205%5D%29%29\u0026cumulative=false\u0026curInstr=0\u0026heapPrimitives=nevernest\u0026mode=display\u0026origin=opt-frontend.js\u0026py=js\u0026rawInputLstJSON=%5B%5D\u0026textReferences=false)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanower77%2Fdata-structures-algorithm-dsa-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanower77%2Fdata-structures-algorithm-dsa-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanower77%2Fdata-structures-algorithm-dsa-/lists"}