Blog

Coursehelp
February 6, 2019
QUESTION : No Comments

A public key infrastructure (PKI) is an integrated set of hardware, software,

Step 1 of 1

A public key infrastructure (PKI) is an integrated set of hardware, software, encryption methodologies and its protocols, legal agreements and third party services that enable the users to communicate securely. It also includes authorized certifications and digital certificates.

A typical PKI solution protects the transmission

OR
OR

Have a Comment on this Question?

Questions viewed by other students


  • QUESTION : (Solved) : Code Public Class Arraysorter Insertion Sort Public Static Void Insertionsort T Int N Inse Q32239286 . . .

    The Algorithm 8.23 The heart of the Shell sort is the adaptation of the insertion sort to work on a subarray of equally spaced entries. By combining and modifying the two algorithms that describe the insertion sort, as given in Segment 8.10, we obtain the following algorithm that sorts array entries whose indices are separated by an increment of space Algorithm incrementalInsertionSort(a, first, last, space) Sorts equally spaced entries of an array a [first..1ast] into ascending order // first >= 0 and < a.length; last >= first and < a.length; // space is the difference between the indices of the entries to sort for (unsorted-first space through last at increments of space) nextToInsert = a[unsorted] indexunsorted space while ( (index >= first) and (nextToInsert.compareTo(a[index)) < 0) ) a[index index = index + space] a[index] = space a[index space] nextToInsert A method to perform a Shell sort will invoke incrementalInsertionSort and supply any sequence of spacing factors. For example, the following algorithm uses the spacing that Segment 8.22 described: Algorithm shellSort(a, first, last) Sorts the entries of an array a first..last] into ascending order first-0 anda.Tength; 1astfirst and<a.length nnumber of array entries space n / 2 Comparing the Algorithms 263 while (space 0) for (begin-first through first+space 1) incrementalInsertionSort(a, begin, last, space) space space 2

    this is the code :

    public class ArraySorter {

    // INSERTION SORT

    public static <T extends Comparable<? super T>>

    void insertionSort(T[] a, int n) {

    insertionSort(a, 0, n – 1);

    } // end insertionSort

    public static <T extends Comparable<? super T>>

    void insertionSort(T[] a, int first, int last) {

    for (int unsorted = first + 1; unsorted <= last; unsorted++){ // Assertion: a[first] <= a[first + 1] <= … <=a[unsorted – 1]

    T firstUnsorted = a[unsorted];

    insertInOrder(firstUnsorted, a, first, unsorted – 1);

    } // end for

    } // end insertionSort

    private static <T extends Comparable<? super T>>

    void insertInOrder(T anEntry, T[] a, int begin, int end) {

    int index = end;

    while ((index >= begin) &&(anEntry.compareTo(a[index]) < 0)) {

    a[index + 1] = a[index]; // Make room

    index–;

    } // end for

    // Assertion: a[index + 1] is available

    a[index + 1] = anEntry; // Insert

    } // end insertInOrder

    // SHELL SORT

    public static <T extends Comparable<? super T>>

    void shellSort(T[] a, int n) {

    shellSort(a, 0, n – 1);

    } // end shellSort

    /**

    * Sorts equally spaced elements of an array into ascendingorder.

    *

    * @param a An array of Comparable objects.

    * @param first An integer >= 0 that is the index of the firstarray element

    * to consider.

    * @param last An integer >= first and < a.length that isthe index of the

    * last array element to consider. @param space The differencebetween the

    * indices of the

    eleme

    * nts to sort.

    */

    public static <T extends Comparable<? super T>>

    void shellSort(T[] a, int first, int last) {

    int n = last – first + 1; // Number of array entries

    int space = n / 2;

    while (space > 0) {

    for (int begin = first; begin < first + space; begin++) {

    incrementalInsertionSort(a, begin, last, space);

    } // end for

    space = space / 2;

    } // end while

    } // end shellSort

    // BETTER SHELL SORT

    /**

    * Avoids even spacing

    */

    public static <T extends Comparable<? super T>>

    void betterShellSort(T[] a, int n) {

    betterShellSort(a, 0, n – 1);

    } // end betterShellSort

    // Exercise 14, Chapter 8

    public static <T extends Comparable<? super T>>

    void betterShellSort(T[] a, int first, int last) {

    int n = last – first + 1; // Number of array elements

    for (int space = n / 2; space > 0; space = space / 2) {

    if (space % 2 == 0) // If space is even, add 1

    {

    space++;

    }

    for (int begin = first; begin < first + space; begin++) {

    incrementalInsertionSort(a, begin, last, space);

    }

    } // end for

    } // end betterShellSort

    private static <T extends Comparable<? super T>>

    void incrementalInsertionSort(T[] a, int first, int last, intspace) {

    int unsorted, index;

    for (unsorted = first + space; unsorted <= last;

    unsorted = unsorted + space) {

    T nextToInsert = a[unsorted];

    index = unsorted – space;

    while ((index >= first) &&(nextToInsert.compareTo(a[index]) < 0)) {

    a[index + space] = a[index];

    index = index – space;

    } // end while

    a[index + space] = nextToInsert;

    } // end for

    } // end incrementalInsertionSort

    } // end ArraySorter

    The Algorithm 8.23 The heart of the Shell sort is the adaptation of the insertion sort to work on a subarray of equally spaced entries. By combining and modifying the two algorithms that describe the insertion sort, as given in Segment 8.10, we obtain the following algorithm that sorts array entries whose indices are separated by an increment of space Algorithm incrementalInsertionSort(a, first, last, space) Sorts equally spaced entries of an array a [first..1ast] into ascending order // first >= 0 and = first and = first) and (nextToInsert.compareTo(a[index)) Show transcribed image text

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Provided Kotlin Needs Changed Object Oriented Style Instructions Provided Within Code Q31155907 . . .

    The code Provided in Kotlin, needs to be changed intoobject-oriented style. All instructions are provided within thecode as comments. Please change it accordingly.

    import java.io.File// this function wouldn’t be needed if using a collection like a// mutable list, arraylist, etc — they can dynamically grow bigger// all this function does is figure out how many lines are in the filefun filesize(): Int { val dataset = File(“src/resources/dataset.txt”).bufferedReader() var fsize = 0 while (true) { val line = dataset.readLine() if (line == null) return fsize fsize += 1 } }// this is NOT a object-oriented program – it reads// a file into three arrays so that name[i] is the // name of the person from record i of the file, // idnum[i] is the id number of that person, and // amount[i] is an amount for that person // Your goal is to rewrite or refactor this program // so that it has a minimal main program, and puts // the code into class, method, object, companion // object, etc — more Object Oriented style of programfun main(args: Array<String>) { // read the input into name, idnum, and amount arrays val n = filesize() val name = Array<String>(n,{i -> “”}) val idnum = Array<Int>(n,{i -> 0}) val amount = Array<Double>(n,{i -> 0.0}) // read the file into the arrays val dataset = File(“src/resources/dataset.txt”).bufferedReader() for (i in 0 until n) { val line = dataset.readLine() if (line == null) break val fields = line.split(“,”) name[i] = fields[0] idnum[i] = fields[1].toInt() amount[i] = fields[2].toDouble() } // make a function to print one record using the arrays fun show(indx:Int): String = “Record(${name[indx]},${idnum[indx]},${amount[indx]})” // make a function to look up a name, returning an index fun lookupName(find:String): Int { for (i in 0 until name.size) { if (find == name[i]) return i } return -1 // if name not found } // make a function to find index of maximum amount fun maxAmount(): Int { var maxamt = 0.0 var rememberIndex = 0 for (i in 0 until amount.size) { if (amount[i]>maxamt) { maxamt = amount[i] rememberIndex = i } } return rememberIndex } fun setAmount(newamt:Double,indx:Int) { amount[indx] = newamt } fun setAmount(newamt:Double,name:String) { amount[lookupName(name)] = newamt } fun setIdnum(newid:Int,index:Int) { idnum[index] = newid } fun setIdnum(newid:Int,name:String) { idnum[lookupName(name)] = newid } // here is some simple testing of these functions and the data val samplename1 = “HDQJwSQdyyFh” println(“Lookup of $samplename1 is ${show(lookupName(samplename1))} ) setIdnum(123456789,samplename1) println(“Revised Lookup of $samplename1 is ${show(lookupName(samplename1))} ) val samplename2 = name[29] println(“Lookup of $samplename2 is ${show(lookupName(samplename2))} ) setAmount(88888.88,samplename2) println(“Revised Lookup of $samplename2 is ${show(lookupName(samplename2))} ) }

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Python Itis Part Tsp Problem Checking Order Pick Two Cities Proposing New Move Improv Q26164397 . . .

    This code is in Python, itis part of a TSP problem is forchecking that in order to pick two cities for proposing a new move(improvement with simulated annealing) it is better to use move1instead of move2 because the first gives couples from a uniformdistribution while the second does not.

    I don’t understand what the function destructure (in bold) does.Please explain it to me.

    import numpy as np
    import matplotlib.pyplot as plt

    def move1(n):
        while True:
            i =np.random.randint(n)
            j =np.random.randint(n)
            if i > j:
               i, j = j, i
            break
        return i,j

    def move2(n, sample_size=10**2):
        for i in range(sample_size):
            i =np.random.randint(n-1)
            j =np.random.randint(i+1, n)
        return i,j

    def destructure(moves):
        mi = [x[0] for x in moves]
        mj = [x[1] for x in moves]
        return mi, mj

    def test_moves(n=10, sample_size=10**2):
        t1 = [move1(n) for k inrange(sample_size)]
        t2 = [move2(n) for k in range(sample_size)]

        t1i, t1j = destructure(t1)
        t2i, t2j = destructure(t2)
      
            # plot the i’s
        plt.clf()   # note: clf() is betterthan cla() since we’re using subplots
                   #       at the end (see below).
        plt.title(“historgram of the i values”)
        plt.hist(t1i, bins=n-1, histtype=’step’,label=’move1′)
        plt.hist(t2i, bins=n-1, histtype=’step’,label=’move2′)
        plt.legend(loc=’upper right’)
        plt.pause(2)
      
    #    # plot the j’s
    #    plt.clf()
    #    plt.title(“historgram of the j values”)
    #    plt.hist(t1j, bins=n-1, histtype=’step’,label=’move1′)
    #    plt.hist(t2j, bins=n-1, histtype=’step’,label=’move2′)
    #    plt.legend(loc=’upper left’)
    #    plt.pause(2)
    #  
    #    # 2-d plots, first move1 then move2
    #    plt.clf()
    #    plt.title(“move1 histogram”)
    #    plt.hist2d(t1i, t1j, bins=(n-1, n-1))
    #    plt.pause(2)
    #    plt.title(“move2 histogram”)
    #    plt.hist2d(t2i, t2j, bins=(n-1, n-1))
    #    plt.pause(2)
      
        # same as above, both plots at once
        plt.clf()
        plt.subplot(211)
        plt.title(“move1 vs move 2 histogram”)
        plt.hist2d(t1i, t1j, bins=(n-1, n-1))
        plt.subplot(212)
        plt.hist2d(t2i, t2j, bins=(n-1, n-1))
        plt.pause(2)

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Python First Ghesoon Last Name Karim Stores First Name Variable Using Lowercase Lette Q30177665 . . .

    code in Python

    first: ghesoon

    last name: karim

    Stores your first name as a variable using all lowercaseletters

    Stores your last name as a variable using all uppercaseletters

    Prints out, “Hello, <first name> <last name>” withthe first name converted to uppercase letters and the last nameconverted to lowercase letters

    Prints out two newlines

    Prints out the following:

    “Start by doing what’s necessary; then do what’s possible; andsuddenly you are doing the impossible – Francis ofAssisi”

    Your output must have quotes at the beginning and the end of youroutputted text

    Stores 2 decimal numbers as variables

    Stores one addition, one subtraction, one multiplication, andone division operation of these variables as variables

    Prints out each of the four results as:

    <numeric value of variable 1> plus <numeric value ofvariable 2> equals <value of variable that stored the resultof addition>

    <numeric value of variable 1> minus <numeric value ofvariable 2> equals <value of variable that stored the resultof subtraction>

    …etc. Each output should be on its own line

    Stores the current month as a string variable (e.g. March, June,etc.) and day of the month as a numeric variable

    Outputs “Today is day <day of month> of the month of<month variable>.

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Python Even Asking Q31712408 . . .

    How do I code this in Python? What is it even asking?

    Eratosthenes (276-195 BC) was a Greek mathematician, geographer, poet, astronomer and music theorist. He was a man of learning, becoming the chief librarian at the Library of Alexandria. He invented the discipline of gcography, including the terminology used today He is best known for being the first person to calculate the circumference of the Earth, which he did by comparing altitudes of the mid-day sun at two places a known North-South distance apart. His calculation was remarkably accurate. He was also the first to calculate the tilt of the Earths axis (again with remarkable accuracy). Additionally, he may have accurately calculated the distance from the Earth to the Sun and invented the leap day. He created the first map of the world, incorporating parallels and meridians based on the available geographic knowledge of his era. Eratosthenes was the founder of scientific chronology; he endeavored to revise the dates of the chief literary and political events from the conquest of Troy. Eratosthenes dated The Sack of Troy to 1183 BC. In number theory, he introduce a scheme whose pseudocode is as below. Convert this to Python and explain (line by line) what each line of your code does. Run it for different n up to n 1000. Input: an integer n> 1. Let A be an array of Boolean values, indexed by integers 2 to n initially all set to true. fori 2,3,4,.., not exceeding vn: if Ali] is true for j i**2 , i** 2+i, i* *2+2, i**2+31, , not exceeding n: AU1 false.

    Eratosthenes (276-195 BC) was a Greek mathematician, geographer, poet, astronomer and music theorist. He was a man of learning, becoming the chief librarian at the Library of Alexandria. He invented the discipline of gcography, including the terminology used today He is best known for being the first person to calculate the circumference of the Earth, which he did by comparing altitudes of the mid-day sun at two places a known North-South distance apart. His calculation was remarkably accurate. He was also the first to calculate the tilt of the Earth’s axis (again with remarkable accuracy). Additionally, he may have accurately calculated the distance from the Earth to the Sun and invented the leap day. He created the first map of the world, incorporating parallels and meridians based on the available geographic knowledge of his era. Eratosthenes was the founder of scientific chronology; he endeavored to revise the dates of the chief literary and political events from the conquest of Troy. Eratosthenes dated The Sack of Troy to 1183 BC. In number theory, he introduce a scheme whose pseudocode is as below. Convert this to Python and explain (line by line) what each line of your code does. Run it for different n up to n 1000. Input: an integer n> 1. Let A be an array of Boolean values, indexed by integers 2 to n initially all set to true. fori 2,3,4,.., not exceeding vn: if Ali] is true for j i**2 , i** 2+i, i* *2+2, i**2+31, , not exceeding n: AU1 false. Show transcribed image text

    Expert Answer


    . . .


    view full answer