GithubHelp home page GithubHelp logo

blasanka / data-structures Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 33 KB

You will find this repo useful for to understand how basic Data Structures and Algorithms can be implemented using Java. Note: this is not containing Java generics features and Java 8, 9, 10 features because main purpose is not to focus in specific language(anyone can use same logic to other languages only the syntax differ)

Java 100.00%
algorithms data-structures java

data-structures's Introduction

Borala Liyanage Asanka ๐Ÿ‘จโ€๐Ÿ’ป :bowtie:

Youtube creator | Blogger | Open source contributor

Github Badge Linkedin Badge Stackoverflow Badge Gmail Badge Whatsapp Badge Facebook Badge

Hi! I'm Asanka, a Sri Lankan Software Engineer mostly working on mobile development and a lover of Flutter framework. I'm have a Bsc in Information Technology. Learning new technologies, developing ideas and helping other programmers around the world is my pleasure.

Languages that I'm having experience:

  • Dart
  • Java
  • Kotlin
  • Swift
  • Javascript
  • Python
  • PHP

Looking forward to support from knowledge or with a software solution. ๐Ÿ†“

data-structures's People

Contributors

blasanka avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

data-structures's Issues

selection sort

def selectionSort(A):
    for j in range(len(A)):
        min = j
        for i in range(j+1,len(A)):
            if A[min] > A[i]:
                min = i
        temp = A[j]
        A[j] = A[min]
        A[min] = temp


arr = [1, -9, 3, 7]
selectionSort(arr)
print(arr)

quicksort

def partition(A, low, high):
    pivot = A[high]
    i = low -1
    for j in range(low, high):
        if A[j] <= pivot:
            i = i + 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[high] = A[high], arr[i + 1]
    return i + 1


def quickSort(A, low, high):
    if low < high:
        q = partition(A, low, high)
        quickSort(A, low, q-1)
        quickSort(A, q+1, high)

arr = [20,51,11,1]
quickSort(arr, 0, len(arr)-1)
print(arr)

insertion sort

a = [3, 7, 4, 1, 8]

for index in range(1,len(a)):
    current = a[index]
    i = index

    while i>0 and a[i-1] > current:
        a[i] = a[i-1]
        i = i -1

    a[i] = current



print(a)

#lab session-------------------

A = []

for v in range(10):
    A.append(input('Enter a number: '))

print('\nunsorted array')
print A

def insertionSort(A):
    for j in range(1, len(A)):
        key = A[j]
        i = j - 1

        while(i >= 0 and A[i] > key):
            A[i+1] = A[i]
            i = i-1
        A[i+1] = key

insertionSort(A)

print('\nsorted array')
print(A)

print('\nsorted array elemenet by element')
for i in range(len(A)):
    print(A[i])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.