Given an array arr[] of N integers. Do the following operation n-1 times

For every Kth operation: Right rotate the array clockwise by 1. Delete the (n-k+1)th last element.


A = {1, 2, 3, 4, 5, 6}. Rotate the array clockwise i.e. after rotation the array A = {6, 1, 2, 3, 4, 5} and delete the last element that is {5} so A = {6, 1, 2, 3, 4}. Again rotate the array for the second time and deletes the second last element that is {2} so A = {4, 6, 1, 3}, doing these steps when he reaches 4th time, 4th last element does not exists so he deletes 1st element ie {1} so A={3, 6}. So continuing this procedure the last element in A is {3}, so outputp will be 3

How to solve this?

How do I prove or disprove the following statements?

I have to prove or disprove the following statements.

a) ≈(L(X)) ⊆ ≈(L(Y)) ⇒ ~(X) ⊆ ~(Y)

b) L(X) ⊆ L(Y) ⇒ ~(X) ⊆ ~(Y)

Definitions:  DFA:M=(K,Σ,q0,δ,F) x~y : ∃q∈Q (q0,x) |-- (q,λ) and (q0,y) |-- (q,λ) x≈y : ∀z∈Σ* xz∈L ⇔ yz∈L 

My problem is the formal proof.

I could show that L(X) ⊆ L(Y) ⇒ ~(X) ⊆ ~(Y) with the help of an exmaple, but that doesn’t show that it applies to all.

And the main problem is to show ~(X) ⊆ ~(Y) or ≈(L(X)) ⊆ ≈(L(Y)), because I don’t really get what that means and when or why it is a subset.

Maybe on of you has an idea to prove or disprove the statements.

Does timestamp protocol following thomas’s write rule allow non-view-serializable schedules in some cases?

I have came across following line in text book (Database System Concepts Textbook by Avi Silberschatz, Henry F. Korth, and S. Sudarshan $ 6e$ ) page no. 686:

Thomas’ write rule allows schedules that are not conflict serializable but are nevertheless correct. Those non-conflict-serializable schedules allowed satisfy the definition of view serializable schedules (see example box).

What I understood from above lines is that every schedule generated by timestamp protocol following thomas’s write rule is view serializable.

Now let’s take following little schedule: $ S: R_1(X), W_2(X), W_1(X)$ .

This schedule $ S$ is allowed under timestamp protocol which follows thomas’s write rule.

And serialization order is $ R_1(X), W_1(X).$

But I was not able to prove that it is view serializable.

Actually I think that it is non-view serializable because,

  1. Consider serial order as $ T_1, T_2$

    Now final value of $ X$ is being written by $ T_2$ . So not equivalent.

  2. Next alternative serial order is $ T_2, T_1$

    here, $ R_1(X)$ will read value of $ X$ written by $ T_1$ not original value which was there before start of both transaction. So this too is not view-equivalent.

What is going wrong here. please help me with this one.

Is it possible to do ‘Oracle Cloud Infrastructure Certifications’ without following ‘SQL Fundamentals | 1Z0-06’? [on hold]

I recently switched my career from SE to Oracle DBA. Currently, the company that I’m working is in progress of switching to a cloud system. As a beginner is it possible to do complete ‘Oracle Cloud Infrastructure Certifications’ without ‘SQL Fundamentals | 1Z0-06’.And note that, I do have good self-studied architectural knowledge about oracle DB and good experience in SQL and PLSQL(from my previous SE career)

How does the HTTPS server know where to get public or private key in following example

I was going through the following tutorial to set up an HTTPS connection, and noticed that it seems the code only makes use of server.crt and server.key (I’m not sure if server.key is the public or private key in the RSA key pair). But shouldn’t two keys be needed for HTTPS? (both public and private keys?).

Altogether, the tutorial covers generation of the following files:

ca.crt ca.key client.crt client.csr client.key server.crt server.csr server.key  

But the node.js code only seems to make use of server.crt and server.key:

const express = require('express') const fs = require('fs') const https = require('https') const path = require('path')  const app = express() const directoryToServe = 'client'  const port = 3443  app.use('/', express.static(path.join(__dirname,'..',directoryToServe)))  const httpsOptions = {     cert: fs.readFileSync(path.join(__dirname,'ssl','server.crt')),     key: fs.readFileSync(path.join(__dirname,'ssl','server.key')) }  https.createServer(httpsOptions,app)     .listen(port, function() {         console.log(`Serving the '$  {directoryToServe}' directory at localhost:$  {port}`)     })   

My understanding of HTTPS is that:

  1. The server sends the client a public key
  2. The client returns a symmetric key encrypted with the public key
  3. the server decrypts the symmetric key using the private key
  4. the client and server communicate using the symmetric key

But as the code above uses only one key server.key (which I assume is the public key?), how does the HTTPS communication work since I assume both assymetric keys should be needed (public and private) to negotiate the symmetric key exchange?

Here is the code to generate the keys/certificates:

#!/bin/bash  # set values for certificate DNs # note: CN is set to different values in the sections below ORG="000_Test_Certificates"  # set values that the commands will share VALID_DAYS=360 CA_KEY=ca.key CA_CERT=ca.crt CLIENT_KEY=client.key CLIENT_CERT=client.crt CLIENT_CSR=client.csr CLIENT_P12=client.p12 SERVER_KEY=server.key SERVER_CERT=server.crt SERVER_CSR=server.csr KEY_BITS=2048  echo echo "Create CA certificate..." CN="Test CA" openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:$  KEY_BITS -out $  CA_KEY openssl req -new -x509 -days $  VALID_DAYS -key $  CA_KEY -subj "//CN=$  CN\O=$  ORG" -out $  CA_CERT echo "Done."  echo echo "Creating Server certificate..." CN="localhost" openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:$  KEY_BITS -out $  SERVER_KEY openssl req -new -key $  SERVER_KEY -subj "//CN=$  CN\O=$  ORG" -out $  SERVER_CSR openssl x509 -days $  VALID_DAYS -req -in $  SERVER_CSR -CAcreateserial -CA $  CA_CERT -CAkey $  CA_KEY -out $  SERVER_CERT echo "Done."  echo echo "Creating Client certificate..." CN="Test User 1" USER_ID="testuser1" P12_PASSWORD= openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:$  KEY_BITS -out $  CLIENT_KEY openssl req -new -key $  CLIENT_KEY -subj "//CN=$  CN\O=$  ORG\UID=$  USER_ID" -out $  CLIENT_CSR openssl x509 -days $  VALID_DAYS -req -in $  CLIENT_CSR -CAcreateserial -CA $  CA_CERT -CAkey $  CA_KEY -out $  CLIENT_CERT openssl pkcs12 -in $  CLIENT_CERT -inkey $  CLIENT_KEY -export -password pass:$  P12_PASSWORD -out $  CLIENT_P12 echo "Done."  echo echo "----- Don't forget to open your browser and install your $  CA_CERT and $  CLIENT_P12 certificates -----" echo 

Thank you in advance!

How to solve following problem using segment trees?

See the following link for better understanding of problem. In brief suppose i have given an array of size n corresponding to permutation of $ [1,2,3 …… n]$ , whose $ ith$ element (say $ s_i$ ) is sum of all $ p_j$ such that $ j<i$ and $ p_j < p_i$ .

How to solve this problem using segment trees in O($ nlogn$ ) (We can solve this in O(n$ ^2$ ) by brute force).

I tried to understand the solution but i failed .Thus asking for help (I tried for 1 whole day)