Langsung ke konten utama

Postingan

Menampilkan postingan dari Juli, 2019

Link ke website ISTN

istn.ac.id

Program Java Sorting List

Ini Codenya: Github public class sortinglist {     node head;     node sorted;       class node     {         int val;         node next;           public node(int val)         {             this.val = val;         }     }       void push(int val)     {         node newnode = new node(val);         newnode.next = head;         head = newnode;     }       void insertionSort(node headref)     {         sorted = null;         node current = headref;         while (current != null)         {                 node next = current.nex...

Program Java Insert List Bilangan dengan Linked List

Ini Codenya: Github class LinkedList {       static Node head1, head2;       static class Node {           int data;         Node next;           Node(int d) {             data = d;             next = null;         }     }       Node addTwoLists(Node first, Node second) {         Node res = null;         Node prev = null;         Node temp = null;         int carry = 0, sum;           while (first != null || second != null)         {             sum = carry + (first != null ? first.data : 0)                     + (second != null ? second.data : 0); ...

Program Java Operasi Pecahan

Ini Codenya: Github public class Fraction {     int numerator;     int denominator;     public Fraction(int numr, int denr) { numerator = numr; denominator = denr; reduce();     }     public int getNumerator() { return numerator;     }     public void setNumerator(int numerator) { this.numerator = numerator;     }     public int getDenominator() { return denominator;     }     public void setDenominator(int denominator) { this.denominator = denominator;     }     public int calculateGCD(int numerator, int denominator) { if (numerator % denominator == 0) {              return denominator;         } return calculateGCD(denominator, numerator % denominator); }     void reduce() { int gcd = calculateGCD(numerator, denominator); numerator /= ...

Program Java Double Linked List Traversal

Ini Codenya: Github public class Doublelinkedlist { Node head; class Node { int data; Node prev; Node next; Node(int d) { data = d; } } public void push(int new_data) { Node new_Node = new Node(new_data); new_Node.next = head; new_Node.prev = null; if (head != null) head.prev = new_Node; head = new_Node; } public void InsertAfter(Node prev_Node, int new_data) { if (prev_Node == null) { System.out.println("The given previous node cannot be NULL "); return; } Node new_node = new Node(new_data); new_node.next = prev_Node.next; prev_Node.next = new_node; new_node.prev = prev_Node; if (new_node.next != null) new_node.next.prev = new_node; } void append(int new_data) { Node new_node = new Node(new_data); Node last = head; new_node.next = null; if (head == null) { new_node.prev = null; head = new_node; return; } while (last.next != null) ...

Program Java Adt tanggal

ini Codenya: Github import java.util.Scanner; public class Adttanggal {         public static void main(String[] args) {         Scanner input = new Scanner(System.in);         int hari = 0;         int tanggal,bulan,tahun,kabisat;         String bln = null ;                 String nama_bulan [] = {"Januari","Februari","Maret","April","Mei","Juni","Juli",               "Agustus","September","Oktober","November","Desember"};                 System.out.print("Masukkan Tanggal : ");         tanggal = input.nextInt();         System.out.print("Masukkan Bulan : ");         bulan = input.nextInt();         System.out.print("Masukkan Tahun : ");         tahu...

Program Python Aplikasi Penambahan Bilangan Array

Ini Codenya: Github x = [22, 46, 32] z = [42, 15, 17] # Menghitung jumlah nilai semua array xTotal = sum(x) zTotal = sum(z) jumlah = xTotal + zTotal print("Jumlah Nilai Kedua Array :", jumlah) # Menggabungkan data dari kedua array print("Gabungan Array") print(x + z)

Program Python Aplikasi Circular Linked List

Ini Codenya: Github class Node:     def __init__(self, data):         self.data = data         self.next = None class CircularLinkedList:     def __init__(self):         self.head = None     def prepend(self, data):         new_node = Node(data)         cur = self.head         new_node.next = self.head         if not self.head:             new_node.next = new_node         else:             while cur.next != self.head:                 cur = cur.next             cur.next = new_node         self.head = new_node     def append(self,data):         if not self.head:           ...

Program Python Aplikasi Menghitung Pecahan Campuran

Ini Codenya: Github class Pecahan:     def __init__(self, bulat = 0, pembilang = 0, penyebut = 1):         self.bulat = bulat         self.pembilang = pembilang         self.penyebut = penyebut     def __add__(self, other):         bulat_baru = self.bulat + other.bulat         if (self.penyebut == other.penyebut):                                      pembilang_baru = self.pembilang + other.pembilang             if pembilang_baru % self.penyebut == 0:                                    bulat_baru += pembilang_baru//self.penyebut                 return Pecahan(bulat_baru, 0, self.penyebut)   ...

Program Python Aplikasi Double Linked List

Ini Codenya: Github class Node:     def __init__(self, data):         self.data = data         self.next = None              self.prev = None class DoubleLinkedList:     def __init__(self):         self.head = None     def append(self, data):         if self.head is None:             new_node = Node(data)             new_node.prev = None                      self.head = new_node         else:             new_node = Node(data)             cur = self.head             while cur.next:                 cur = cur.next             cur.n...

Program Python Aplikasi Insert List Urut

Ini Codenya: Github list = [1,3,2,6,4,8,5,9,13,11,10] (print("List Awal") print(list) print("Menambahkan Data List dengan Insert") list.insert(7,33) print(list) print("Mengurutkan List") list.sort() print(list)

Program Python Priority Queue

ini codenya: Github class PriorityQueue(object):     def __init__(self):         self.queue = []     def __str__(self):         return ''.join([str(i) for i in self.queue])     def isEmpty(self):         return len(self.queue) == []     def insert(self, data):         self.queue.append(data)     def delete(self):         try:             max = 0             for i in range(len(self.queue)):                 if self.queue[i] > self.queue[max]:                     max = i             item = self.queue[max]             del self.queue[max]             return item     ...