Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:48:31+00:00 2026-06-17T08:48:31+00:00

What is the best Data Structure(DS)/Class I can use to implement Caesar’s Cipher ?

  • 0

What is the best Data Structure(DS)/Class I can use to implement Caesar’s Cipher ? This is what I have thought of so far:

  1. String with all alphabets (abc…zABCD…Z) ?
  2. Array with alphabets and wraparound ?
  3. DS which stores a key value pair ?

Why i thought i need 3 – I have to find the character (which is to be encoded) in my “list of numbered alphabets”. Then i use that index, and shift it by a number. I thought that it would be faster if i used key value pair instead of searching each index of string or array.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:48:32+00:00Added an answer on June 17, 2026 at 8:48 am
    public String applyCaesar(String text, int shift)
    {
        char[] chars = text.toCharArray();
        for (int i=0; i < text.length(); i++)
        {
            char c = chars[i];
            if (c >= 32 && c <= 127)
            {
                // Change base to make life easier, and use an
                // int explicitly to avoid worrying... cast later
                int x = c - 32;
                x = (x + shift) % 96;
                if (x < 0) 
                  x += 96; //java modulo can lead to negative values!
                chars[i] = (char) (x + 32);
            }
        }
        return new String(chars);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder what is the best C# data structure I should use to sort
This question can best be asked by example. Say I have a database table
Possible Duplicate: What data-structure should I use to create my own “BigInteger” class? Out
What's the best data structure (in java) for the task of loading 51 million
What is the best data structure to store an oracle table that's about 140
What's the best data structure for a 2D array of size unknown x 2.
What would be the best data structure to store all the words of a
I'm looking for a Java built-in data structure that would be the best at
I am trying to determine which implementation of the data structure would be best
Say I have a Group data structure which contains a list of Element objects,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.