Category: sort scala

The Version 6 of Angular Now Update 11/05/2018

As a part of this release, we are synchronizing the major versions going forward for the framework packages (@angular/core, @angular/common, @angular/compiler, etc), the Angular CLI, and Angular Material + CDK. All are releasing as 6.0.0 today. We made this change to clarify cross compatibility. The minor and patch releases for these projects will be issued based on … Continue reading The Version 6 of Angular Now Update 11/05/2018

Advertisements

HeapSort in Scala – this is coding algorithm

import scala.collection.mutable.ArraySeq object HeapSort { def sort(vals: ArraySeq[Int]) { var heap = new MaxHeap heap.set(vals) for (i <- vals.length - 1 to 0 by -1) { vals(i) = heap.deleteMax } } } class MaxHeap { var _vals: ArraySeq[Int] = _ // First element is in 1, not 0. def set(vals: ArraySeq[Int]) { _vals = new … Continue reading HeapSort in Scala – this is coding algorithm

Selection Sort in Scala-This is coding algorithm

object Sort{ def selectionSort () : Unit = { var myArray = Array(4, 7, 8, 3, 1, 9, 2, 5, 0, 6) var buf:Int = 0; var min:Int = 0; for(i <- 0 to (myArray.length-1)) { min = i // j = i + 1; for (j <- (i+1) to (myArray.length)){ if ( myArray(min) > … Continue reading Selection Sort in Scala-This is coding algorithm

This is coding algorithm – Scala code bubble sort for loop

object Sort{ def bubbleSort () : Unit = { var myArray = Array(4, 7, 8, 3, 1, 9, 2, 5, 0, 6) var buf:Int = 0; for(i <- 0 to (myArray.length-1)) { for (j <- 1 to (myArray.length)){ if (myArray(j) < myArray(j-1)){ buf = myArray(j) myArray(j) = myArray(j-1) myArray(j-1) = buf } } } println("SORTED") … Continue reading This is coding algorithm – Scala code bubble sort for loop

Learn about the MVP programming model in android

What is the MVP model? MVP is a user-oriented GUI model, designed to facilitate unit testing and increase segregation between the data layer and the data layer in the MVC model. The MVP model allows the separation of the presentation layer (the Presenter) from the data layer, so interaction with the interface is separate from … Continue reading Learn about the MVP programming model in android

Sort numbers in ascending order using Python

This is Python code to sort the numbers in ascending order input: 3,0,1,4,2 out:0,1,2,3,4 Example is my: numbers = input("Enter numbers separated by a comma: ") numbers = [int(n) for n in numbers.split(',')] end = len(numbers) - 1 while end != 0: for i in range(end): if numbers[i] > numbers[i + 1]: numbers[i], numbers[i + … Continue reading Sort numbers in ascending order using Python

Prime Number Generator (6n + 1 or 6n – 1)

Prime Number Generator (6n + 1 or 6n - 1) This generator is like most where it brute forces an integer: it see whether the integer is divisible by any of the primes; if so, then it's not a prime and vice versa. This though only compares values 6n + 1 and 6n - 1 starting with n as 1 as … Continue reading Prime Number Generator (6n + 1 or 6n – 1)

Collatz Conjecture Meet of 2 Numbers in python

def first_collatz(n, visited): counter = 0 while n > 1: counter += 1 n = 3 * n + 1 if n & 1 else n >> 1 if n not in visited: visited[n] = counter def secondd_collatz(n, other): counter = 0 if n not in other: while n > 1: counter += 1 n … Continue reading Collatz Conjecture Meet of 2 Numbers in python

Simple budget program in python

I've decided to start working on a budget application for the purposes of enhancing my Python skills. In its current form this program takes given expenses and income and tells the user whether they have a surplus, a deficit, or if they are breaking even. Example: import os import sys class Application(): def __init__(self): self.income … Continue reading Simple budget program in python