How to write the invariants for one version of binary search insertion point (or leftmost entry) algorithm?

If we compare the binary search algorithm (leftmost or insertion point) on Wikipedia:

Algorithm 1:

function binary_search_leftmost(A, n, T):     L := 0     R := n     while L < R:         m := floor((L + R) / 2)         if A[m] < T:             L := m + 1         else:             R := m     return L 

with the one on Rosetta Code:

Algorithm 2:

BinarySearch_Left(A[0..N-1], value) {   low = 0   high = N - 1   while (low <= high) {       // invariants: value > A[i] for all i < low                      value <= A[i] for all i > high       mid = (low + high) / 2       if (A[mid] >= value)           high = mid - 1       else           low = mid + 1   }   return low } 

This binary search is the somewhat more complicated type of binary search, which is to find the leftmost index, or it can be the insertion point (so it is not the “exact match” binary search), as follows:

If the numbers in the array are:

11 22 22 33 44 55 66 

then if the target is 3, then the result should be 0 (3 inserted at index 0).

If the target is 59, then the result should be 6 (inserted at where 66 is), and if the target is 77, then the result should be 7 (inserted to the right of the maximum index, which is adding it as the new, final element).

I found it very easy to establish the invariants and correctness for Algorithm 1:

function binary_search_leftmost(A, n, T):     // Invariant:     // [L, R] inclusive is where the answer could be.     //   so note R is not n - 1 like the "exact match" case, but n,     //   because we can go "one step to the right" to insert     //   as index n     L := 0     R := n      // Invariant:     // note that we keep on looping when L < R, meaning the range     // [L, R] is not "closed".  When L == R, then we have reached     // the answer. Note that unlike the exact match case, here we     // always have an answer, so when L == R, then we already have     // an answer. (because [L, R] is where the answer is, and if     // L === R, we already have the answer either L or R and it cannot     // be anything else)     while L < R:         // Invariant:         // It might be better to use m := L + floor((R - L) / 2)         // here, because of the possible overflow bug. Here we consider         // if L and R differ by 1, such as L == 35 and R == 36, then         // m becomes min(L, R), and down below, since there can be         // only two cases: L := m + 1 which is 36, or R = m which is 35,         // that means the range [L, R] always shrinks.  If L and R          // differ by 2 or more, then it is obvious that [L, R] will         // always shrink.  When L and R differ by 0, the loop will not         // continue. So here we established that there will be no         // infinite loop         m := floor((L + R) / 2)         // if target is, say 55, and A[m] is 25 or 54, now we are         // disqualifying 25...A[m], so we set the lower bound L         // to m + 1 (so we disqualify m as well)         if A[m] < T:             L := m + 1         // Here it is T <= A[m]         // if target is, say 55, and A[m] is 55, 56, 100, or 1000         // now our answer could still be m, because m could be the         // leftmost (we don't know yet), so we don't disqualify m         // and so we disqualify m + 1 and all the way to the end         // of array, so we set R = m         else:             R := m     // Finally, when L == R, we could return either L or R     // In fact, it may be good to assert L == R here     return L 

However, for Algorithm 2, I found it quite difficult to establish invariants. It will be kind of like [low, high + 1] could be where the answer falls into. And if I imagine a high2 === high + 1, then maybe everything can fall into place, with

high = N - 1  high2 = high + 1 = N - 1 + 1 = N   (same as Algorithm 1)  while (low <= high) while (low < high + 1)             (same as Algorithm 1, see below) while (low < high2)                (same as Algorithm 1)  high = mid - 1 high2 = high + 1 = mid - 1 + 1 high2 = mid                        (same as Algorithm 1) 

but the line

mid = (low + high) / 2 

becomes

mid = (low + high2 - 1) / 2 

(I think it is assuming integer arithmetics) so then it is shifting the answer to 0.5 to the left sometimes (and therefore 1 less if taking the floor). But if we look at [low, high] === [35, 37] or [35, 36] or [35, 35], they still work out well. Overall, the invariants seem somewhat awkward and unclear. Are there actually some ways to establish good invariants and correctness for Algorithm 2?

Showing “this is secure” on credit card entry screen

Should I show some sort of “this site is secure” puffery (e.g. lock image, or some brief “this site is secure” boilerplate) on my credit card payment screen? If so, what should it look like? If not, why not?

I do want my customers to feel confident (as well as actually be safe) if they choose to enter their credit card details to pay my clients. I also want them to learn a healthy cynicism. Most of my customers are likely to have a very low level of technical knowledge about internet security and are usually either too trusting, and (in some cases) too suspicious of the wrong things.

I even had a customer call me up saying he wasn’t sure if my payment page was secure because it didn’t have any “padlock” image within the page. (yes, the page had a valid SSL certificate, the customer had the correct URL, and his version of Chrome was showing it with the green padlock with the “Secure” label at the time – after pointing this out he was happy to proceed).

I just feel it’s a bit strange to splash a “this is secure” badge on a page because I know it means nothing, technically – because a phishing page would just as easily show the exact same badge.

Assumption: that my site is actually secure (let’s just say I’ve tried my best and will continue to improve as much as possible).

For reference, here is the page as it currently stands:

Here’s a mockup of what I mean:

UPDATE after some modifications:

What happen if the L1 cache has the address entry with write_back attribute. Will that address be available in L2 cache?

I have the TLB entry for a particular address. This address has write-back attributes in both L1 cache and L2 cache. My queries are: 1> if L1 cache entry has write-back, can it be write-back in L2? 2> if L1 cache entry has write-back, then updated values will not be written into DDR until we apply flush. Does the same behaviour like DDR is applicable for L2 cache also?

I Will High Quality Data Entry, data collection& Web Research Ms Excel 20 Hours for $8

Do you need Reliable and Professional services for Data Entry, Data Mining, Web Research, Business Leads or List Building projects? YES, you are in the right place. I’ll do that for you in the least possible time. I CAN PERFECTLY DO:Online or Offline Data EntryWeb ResearchData MiningData CollectionAdmin SupportData ConversionPDF to ExcelCreation of Mailing Lists in ExcelLinkedin data collectionCreate E-Mail DatabaseWeb scraping. Please do contact me first before placing an order, to avoid cancellation.

by: djExppert
Created: —
Category: Data Entry
Viewed: 395


I will provide any types of Data Entry work. for $10

I am proficient Data Entry Freelancer, I have many years of experience in data entry work. I can complete any complex data entry task as per your instruction. So, you need not worry as I am here to take your burden and make you pleased. Please provide me any type of task related to my services. I will complete it with 100% Accuracy, As per your requirement and the time you will specify. My Services:-Image/PDF to MSExcel or MSWord. Fillable PDF Form. Google Document and Spreadsheet Data Entry. Sales or Purchase Order entry in Excel. Make CSV and KDP File. Information from Web to Word or Excel.Online and Offline Typing Work.HTML Code Writing. Internet Research. File Conversions. Product Data Posting. And Many More. You Will Get (((Fast Delivery/ Confidential/ Responsibility/ Reasonable Price/ Unlimited Revisions))) Please message me for your project details. I will give a supportive response within a few munites.100% Refund if you are not satisfied with my work. Your Freelancer Forever

by: sasankanayak
Created: —
Category: Data Entry
Viewed: 252


Do Perfect Web Research And Data Entry For You for $40

I am a professional Data entry operator and have experience of more than three years in this field. Here is just a short list of My Services; Data Entry (online/Offline) Data Collection Data Analysis Data Mining Copy-Paste Market Research Internet Research/Web Research Contacts Research MS Excel Spreadsheets, Word Documents, Powerpoint Presentation Social Media Accounts management File Conversion (PDF to Excel/Word)

by: spotifyedpromo
Created: —
Category: Onsite SEO & Research
Viewed: 140


Entry points to one location from different products

The scenario

We have one Product that contains a Candidate list in one location in our main database, with its own UI and functionality (standard list admin functionality)

We also have about six different individual internal branded websites/products under our network, but all accessing this main database

User story: As a user of one of these products, I want to be able to gain access/easily add to or create a new candidate list from any of our products UI that i am using, instead of having to log out of whatever product im currently using, and log into this candidate list to perform this action.

So in essence – Have the functionality of the candidate list but retain the look and feel of the product i’m currently using

What do you guys think would be the best approach for this? i was thinking this would could be achieved by a pop up window/Modal window and following a step through process

Or is it best to develop the UI and call an API for this?

Hope this is clear?

I will complete any type of data entry work for you for $8

Services I Provide: Data Entry (All type)Microsoft Office (Word, Excel, Powerpoint)Copy PastePDF to WordPDF to ExcelScanned Pages to Excel/WordLead GenerationOnline or Offline Data InputSocial Media Marketing (Facebook, Twitter, LinkedIn) Keyword ResearchData collecting from the webWeb Research

by: Spotifyedpro
Created: —
Category: Data Entry
Viewed: 111


Do Advance Data Entry And Web search in your time Hello Sir, I’m very proficient and have valuable e for $5

Hello Sir, I’m very proficient and have valuable experience in Data Entry. I can very fast work and timely delivery. My Services List: 1.Web Research and data collecting 2. Online or Offline Data Entry 3.Data Mining 4.Copy-paste 5.Lead generation 6.Data Conversion 7.Company Name, address, mail, contact number 8.Companies Data Research for Business Development Purposes 10.Data collecting from the web 11. MS Word 60+ words per minute without any mistake. Please contact me before ordering to confirm the requirements. i am active 16 hour in a dayCan you Order with ConfidenceThanks

by: Seokingdom2808
Created: —
Category: Data Entry
Viewed: 238